matplotx icon indicating copy to clipboard operation
matplotx copied to clipboard

Feature request: Distribute .mplstyle files

Open joooeey opened this issue 1 year ago • 0 comments

The dufte style looks nice for use with cantools because of the thin lines. Cantools uses a command line script for plotting where one can specify a plotting style with e.g. --style ggplot. I'd like to use --style matplotx.dufte instead (I also tried --style matplotx.styles.dufte). Unfortunately this doesn't work because matplotx doesn't distribute .mplstyle sheets as suggested by the matplotlib API.

I'd like the following to work:

$ mamba install cantools matplotx
$ cantools plot --list-styles .
available matplotlib styles:
- Solarize_Light2
- _classic_test_patch
- _mpl-gallery
- _mpl-gallery-nogrid
- bmh
- classic
[...]
- seaborn-v0_8-white
- seaborn-v0_8-whitegrid
- tableau-colorblind10
- matplotx.aura
- matplotx.ayu
- matplotx.challenger_deep
- matplotx.dhaitz
- matplotx.dracula
- matplotx.dufte
[...]
- matplotx.tokyo_night

However, as it is now, I don't get the matplotx styles.

Then I could run commands like cat can*.log | python -m cantools plot signal_database.dbc * --style matplotx.dufte and get plots with nice thin linewidths.

This is just one use case. I would think there are plenty of other use cases. A trivial one would be that if matplotx distributes .mplstyle sheets, the following

import matplotx
import matplotlib.pyplot as plt
plt.styles.use(matplotx.styles.dufte)

can be shortened to

import matplotlib.pyplot as plt
plt.styles.use("matplotx.dufte")

For all the examples above, I assume that .mplstyle sheets are in the package root directory but according to the style sheet docs, putting the style sheets at e.g. matplotx.styles.aura would work too.

joooeey avatar Dec 11 '24 16:12 joooeey