0

I'm a mathematica newbie!

I want to display 15 plots (5 rows labeled by "A" "B" "C" "D" "E" and 3 columns labeled by "P1" "P2" "P3"). The plots in the first two columns are regular (2D) Plot, whereas the plots in the 3rd column are actually 3DPlot.

For a first try I just focused on plotting the 10 2D plots. Even with that I don't get the table rows and columns names displayed properly (although the graphs seem correct):

rowHeadings = TextCell[ StringJoin[{"Row ",{"A","B","C","D","A"}[[#]]}],FontSize -> s] & /@Range[1,5];
colHeadings =TextCell[{ "P1 ","P2 "}];
Clear[format];
format[plots_, s_: 10] := TableForm[plots, 
  TableHeadings -> {rowHeadings,colHeadings}, 
  TableAlignments -> Center, TableSpacing -> {1, 1}]
parameters = Table[{rowID, colID},{rowID, 1, 5}, {colID, {1,2}}];
myfunc[colID,rowID,x_] :=myfunc[colID,values[[colID]],rowID,x];
myfunc[colID,rowID] := myfunc[colID,rowID,#]&;
functors = Map[myfunc[#[[2]],#[[1]] ]&,parameters,{2}];
Labeled[format[
  Map[Plot[#[x],{x,0,1},
  AspectRatio -> 1,
  FrameTicks->Automatic,
  ImageSize -> 100]&,functors, {2}]],
  Style["Reward function for deviation from initial trait value", 16],Top]

The plots are displayed properly but the Table labels are not shown. Would anyone see why? And next how am I supposed to add the 3rd column with a 3DPlot in this kind of setting? Is it even possible with Mathematica?

WaterFox
  • 185
  • 6
  • 1
    Problem is you've made the entire list {"P1","P2"} a TextCell. Try colHeadings=TextCell/@{"P1","P2"}. Just a heads up, you probably shouldn't use s the way you do in rowHeadings for font size, it seems to work but I'm not sure why. You're leaving s as a global variable, while format should be localizing it. Better to do rowHeadings[s_:10]:=TextCell[...,FontSize->s] then call it with TableHeadings->{rowHeadings[s]}. Also, values in myfunc seems to be undefined. – N.J.Evans Aug 30 '22 at 19:07
  • Thank you! I had no idea what s was doing, so thank you for pointing this out! Thanks for the TextCell fix, I will try this rn! – WaterFox Aug 30 '22 at 19:15
  • 1
    Welcome to the Mathematica Stack Exchange. The introductory book written by the inventor is a good learning resource. There is a fast intro for math students as well as a fast intro for programmers to choose from. – Syed Aug 31 '22 at 04:37
  • 2
    "values" is not defined. Probably it should read: myfunc[colID_, rowID_] and myfunc[colID_, rowID_, x_]. TextCell is not appropriate. – Daniel Huber Aug 31 '22 at 08:29
  • 1
    In addition to Syed's links, this question about common pitfalls is also a good resource since it looks like you have some of the basics down. – N.J.Evans Aug 31 '22 at 12:17
  • Wahoo these resources are clutch! Thank you people! :) – WaterFox Aug 31 '22 at 12:49

0 Answers0