Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why specifying `stylesheet` parameter in plot function causes error?

I'm disappointed by how the default plot style looks, so I decided to find some fancier stylesheet. The official documentation says:

MATPLOTLIB STYLE SHEET OPTION:

`stylesheet` - (Default: classic) Support for loading a full matplotlib style sheet.
Any style sheet listed in matplotlib.pyplot.style.available is acceptable.
If a non-existing style is provided the default classic is applied.

When I try it with a simple example, I get

plot(sin, stylesheet="ggplot")
...
RuntimeError: Error in line(): option 'stylesheet' not valid.

However I found that this alternative works:

plot(sin).show(stylesheet="ggplot")

This is ugly, because I use IPython CLI and want to be able to show the plot by this syntax

p = plot(sin)
p

without typing .show(). Moreover, I'd like to configure my .sage/init.sage file so that the 'ggplot' stylesheet is used by default:

# .sage/init.sage
plot.options["stylesheet"] = "ggplot"

This doesn't work though, for sage substitutes this option into line() function which appears to have no such option.

Questions: 1. Is this a bug, or a mistake in (my understanding of) the documentation? Should it be reported and if yes, where is the best place to do it? 2. How do I achieve custom plotting style by default (perhaps by some setting in the init.sage file)?

I'm using SageMath version 9.5, Release Date: 2022-01-30 with Python 3.10.2, all downloaded from ArchLinux official repos.

Why specifying `stylesheet` parameter in plot function causes error?

I'm disappointed by how the default plot style looks, so I decided to find some fancier stylesheet. The official documentation says:

MATPLOTLIB STYLE SHEET OPTION: `stylesheet` OPTION:

stylesheet - (Default: classic) Support for loading a full matplotlib style sheet. Any style sheet listed in matplotlib.pyplot.style.available is acceptable. If a non-existing style is provided the default classic is applied.

applied.

When I try it with a simple example, I get

plot(sin, stylesheet="ggplot")
...
RuntimeError: Error in line(): option 'stylesheet' not valid.

However I found that this alternative works:

plot(sin).show(stylesheet="ggplot")

This is ugly, because I use IPython CLI and want to be able to show the plot by this syntax

p = plot(sin)
p

without typing .show(). Moreover, I'd like to configure my .sage/init.sage file so that the 'ggplot' stylesheet is used by default:

# .sage/init.sage
plot.options["stylesheet"] = "ggplot"

This doesn't work though, for sage substitutes this option into line() function which appears to have no such option.

Questions: 1.

  1. Is this a bug, or a mistake in (my understanding of) the documentation? Should it be reported and if yes, where is the best place to do it? 2. it?

  2. How do I achieve custom plotting style by default (perhaps by some setting in the init.sage file)?

I'm using SageMath version 9.5, Release Date: 2022-01-30 with Python 3.10.2, all downloaded from ArchLinux official repos.