garrettj403 / SciencePlots

Matplotlib styles for scientific plotting
MIT License
7.12k stars 709 forks source link

IEEE cycler limit #33

Closed eneriz-daniel closed 3 years ago

eneriz-daniel commented 3 years ago

Hi! Just discovered this repo and love how helpful it is.

I've noticed the IEEE style has a detail that is annoying me. The default plot styles are this ones: ieee-default

So it only allows up to 4 different plot styles. I've tried to change the cycles order using

from cycler import cycler
plt.rcParams.update({"axes.prop_cycle": cycler('linestyle', ['-', '--', ':', '-.'])*cycler('color', ['k', 'r', 'b', 'g'])})

to get the linestyles to iterate over the colors, creating up to 16 new ploting styles. ieee-new-cycler

Maybe you want to change it in the repo.

Thanks for sharing your work!

garrettj403 commented 3 years ago

Hi @eneriz-daniel, I'm glad you find SciencePlots useful!

The IEEE style is a bit difficult to design because the plot should be readable in black & white, meaning that all of the line styles should be different. In your example, the solid black, red, blue and green lines will look identical in B&W. In Matplotlib, there are only 4 different line styles which limits the total number of lines in B&W to 4.

If you don't care about B&W readability, you can always override the ieee color cycle:

plt.style.use(['science', 'ieee', 'std-colors'])

In this example, we still get the formatting of the ieee style (figure size, font, etc.) but std-colors overrides the ieee color cycle.

Note: std-colors isn't in the latest release yet. You need to install from the GitHub repo.

eneriz-daniel commented 3 years ago

That's true, hadn't thought in the B&W compatibility. Thanks for your suggestion of std-colors.