0
$\begingroup$

Is there a way to make Mathematica adjust the amount of visual clutter (ticks, tick size, linewidth) depending on ImageSize?

Long version: I would like to include plots from Mathematica in a LaTeX document. Sometimes I want a large plot that is as wide as the paper and sometimes I prefer having (say) three next to each other. I know I can scale figures in Mathematica with ImageSize->Small,Medium,.... However any setting other than Medium makes them visually unpleasing (there are too many ticks in Small figures, the ticks are to thin, the other lines are too thin as well, etc., whereas a large plot might still look mostly empty. I know I can manually do this, but it's quite tedious.

Is there a good way to make Mathematica automatically use less ticks and thicker lines for smaller plots, rather than just scaling them down?

Thank you, and feel free to edit the question if you think it can be posed in a better way.

$\endgroup$
2
$\begingroup$

You can automate this, but obviously only if you have a predefined number of ticks for each image size. You can adjust the range of the ticks to cover all functions, out of bound ticks are not shown.

k = { Small, Medium, Large};
l = {{Table[i, {i, 0, 2, 1}], Table[i, {i, 0, 4, 2}]}, 
  Automatic, {Table[i, {i, 0, 2, 0.1}], Table[i, {i, 0, 4, 0.5}]}};
p1 := Table[Plot[x^2, {x, 0, 2}, ImageSize -> k[[i]], Ticks -> l[[i]]], {i, 3}]

enter image description here

$\endgroup$
  • $\begingroup$ This also requires me to know how the x- & y-range of my plots, something I do not know in advance. But I guess I could turn it into a function, so thanks! $\endgroup$ – Daniel Jun 24 '16 at 13:50
  • $\begingroup$ You could try something like {i,Min[xdata],Max[xdata],Length[xdata]/8}. But like I said, you can just make a table of ticks that covers every part of the real line you are expected to use, out of bound ticks just don't show. Of course, more than that I can't say without knowing more details. $\endgroup$ – Feyre Jun 24 '16 at 13:54
  • 1
    $\begingroup$ Okay, it seems like this manual approach is the only one. I was hoping for Mathematica being a bit smarter and having some nicer Automatic settings. Thanks a bunch! I'll accept your answer in a bit, for now I'll wait a bit in case someone has a better idea. In particular, the line thickness still varies, despite setting a fixed value via PlotStyle->Thickness[.005] $\endgroup$ – Daniel Jun 24 '16 at 14:13
  • 1
    $\begingroup$ @Daniel You may want to try AbsoluteThickness instead. But in general, I agree that Mathematica's abilities for basic scientific plotting haven't kept up with the pace of improvement in other areas. Tick mark handling is one of the recurring issues. $\endgroup$ – Jens Jun 24 '16 at 15:27
  • $\begingroup$ Yay, thanks for pointing out AbsoluteThickness, great stuff :) $\endgroup$ – Daniel Jun 24 '16 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.