Ask Your Question
2

Background for plot should include axes and labels

asked 3 years ago

erentar gravatar image

updated 3 years ago

slelievre gravatar image

Plots in Jupyter: Mathematica vs Sage

Below are four versions of a same plot in Jupyter notebooks in JupyterLab:

  • light theme vs dark theme
  • Mathematica vs Sage, using the Wolfram Language kernel and the SageMath kernel

To reproduce, either use the notebooks: mathematica | sage, or use the following code snippet:

f = 8.252e-5 - 0.035e-10*x
I = (0, 1e5)
labels = ["altitude in meters", "force difference in newtons"]
plot(f, I, axes_labels=labels)

and in JupyterLab, select light or dark via the "Settings > JupyterLab Theme" menu.

Light theme

Left: Mathematica. Right: SageMath.

Dark theme

Left: Mathematica. Right: SageMath.

Observation

In the SageMath plots,

  • the font size is inconsistent between the axis labels and tick labels
  • the white background does not include the axes or tick labels if the plot does not extend to an area covering them; as a consequence, in dark mode,

    • the y-axis label and y-axis tick labels,
    • the x-axis, x-axis label and x-axis tick labels,

    are black on a black background, and cannot be seen.

Question

Could i make the background permanently opaque, and permanently change the font size to something more reasonable like Mathematica has for reference?

Preview: (hide)

Comments

To see larger versions of the pictures, right-click them (or control-click on macOS) and select "Open image in new tab" from the contextual menu offered by your browser.

slelievre gravatar imageslelievre ( 3 years ago )

slelievre, thank you very much, this looks much better.

erentar gravatar imageerentar ( 3 years ago )

This is now tracked at

Thanks for opening that ticket.

slelievre gravatar imageslelievre ( 3 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 3 years ago

eric_g gravatar image

This answers only the question about the font size: use the option axes_labels_size in plot() to set the relative size between the axes labels and the tick labels. The default value is 1.6, which is fine for LaTeX-typset axes labels, but may be too large for non-typeset ones. Use axes_labels_size=1 to get the same size as for the tick labels. See axes_labels_size and show options.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 535 times

Last updated: Apr 28 '21