Group Abstract Group Abstract

Message Boards Message Boards

0
|
20 Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Automatically scale labels based on image size

Posted 12 hours ago

Jupyter screenshot for the following Mathematica code is shown alongside python analogue. The latter scales axes' labels and plot thickness, not the former: is there a Plot[] option for that?

SetOptions[Plot,
  Background -> GrayLevel[0.95],
  AxesStyle -> Black,
  LabelStyle -> Black
];

Plot[Sin[x], {x, 0, 10},ImageSize->100]

jupyter screenshot

P.S. : The reason for SetOptions is the default background is black. Is that a new thing?

POSTED BY: Erwann Rogard
3 Replies
Posted 7 hours ago

It was a wrong assumption of mine that matplotlib automatically scales labels' size and thickness. Here's additional insight about specified/actual image size, and evidence of "background is black". This is all after restarting the kernel:

g=Plot[
  Sin[x],
  {x, 0, 10},
  ImageSize -> 100,
  TicksStyle -> Scaled[.005],
  PlotStyle  -> Thickness[.01]
];
{ImageDimensions[g],ImageSize /. Options[g]}

Show[g]

jupyter screenshot

POSTED BY: Erwann Rogard
Posted 7 hours ago
POSTED BY: Eric Rimbey
Posted 11 hours ago

Caveat: I don't use Jupyter, so I don't know if there is anything about that environment that is relevant to your question. I'm using a Mac and running MMA version 14.3.

Taking your questions in reverse order:

default background is black. Is that a new thing?

I don't know what you're referring to exactly, but I don't see black backgrounds in my plots and the Plot options do not show anything defaulting to black. Specifically, the default for Background is None. Maybe Jupyter somehow displays None as black?

The latter scales axes' labels and plot thickness, not the former: is there a Plot[] option for that?

You can use PlotStyle to adjust the thickness of the line. You can use TickStyle to set FontSize. For example,

Plot[Sin[x], {x, 0, 10}, TicksStyle -> FontSize -> Scaled[.05], PlotStyle -> Thickness[.05]]

But I think you might run into problems using an image size so small. Also, the image you show looks like the image of the plot was actually resized to be larger than 100 after the plot was created, which would explain why the font and line seem large. Maybe that's another Jupyter thing, IDK.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard