Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that rcparam values are unquoted #3670

Open
kfiz opened this issue Oct 18, 2014 · 26 comments
Open

Document that rcparam values are unquoted #3670

kfiz opened this issue Oct 18, 2014 · 26 comments
Assignees
Labels
Documentation keep Items to be ignored by the “Stale” Github Action topic: rcparams

Comments

@kfiz
Copy link

kfiz commented Oct 18, 2014

Hi,
I'm not able to specify the default marker in matplotlibrc.
I tried:
lines.marker : '.'
lines.marker : 'point'
and others. Nothing worked.
What's the right way to do it?
Sry for asking this on the bug tracker, but I didn't now where else to ask.

Cheers

@tacaswell
Copy link
Member

What do you mean by 'not work' . Typically questions like this should go to the user mailing list (matplotlib-users@lists.sourceforge.net you have to sign up for the list to have posting rights) or stackoverflow.com .

@tacaswell tacaswell added this to the unassigned milestone Oct 18, 2014
@kfiz
Copy link
Author

kfiz commented Oct 18, 2014

By "not working" I mean, that once I test these settings by trying to plot a scatter plot, I get an error message:
"ValueError: Unrecognized marker style "." "
Next time I'll address that on the mailing list, thanks.

@tacaswell
Copy link
Member

And what version of mpl are you using?

@kfiz
Copy link
Author

kfiz commented Oct 18, 2014

In [1]: import matplotlib
In [2]: matplotlib.version
Out[2]: '1.4.0'

@tacaswell tacaswell modified the milestones: v1.4.1, unassigned Oct 18, 2014
@tacaswell tacaswell added status: confirmed bug status: needs patch Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Oct 18, 2014
@tacaswell
Copy link
Member

Thanks for reporting this, this actually is a substantial bug. For some reason, when reading from the file it is growing quotes:

In [7]: matplotlib.rcParams['lines.marker']
Out[7]: u"'s'"

@kfiz
Copy link
Author

kfiz commented Oct 18, 2014

Your welcome. Thanks for the quick response.

@tacaswell tacaswell removed Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. status: confirmed bug status: needs patch labels Oct 18, 2014
@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.1 Oct 18, 2014
@tacaswell tacaswell modified the milestones: unassigned, v1.4.x Oct 18, 2014
@tacaswell tacaswell changed the title Setting the default marker in matplotlibrc Document that rcparam values are unquoted Oct 18, 2014
@tacaswell
Copy link
Member

@kfiz Actually, I am way over-reacting. The problem is that, contrary to all python expectations, the values in the .matplotlibrc file go in unquoted.

The correct line is

lines.marker      : .    # the default marker

I have changed your issue title to (in my view) more accurately describe the problem.

@kfiz
Copy link
Author

kfiz commented Oct 18, 2014

Hmm. Well specifying ".", results in "o" not ".", on my machine.
I also tried:
lines.marker : s # the default marker
Which also results in circles, i.e. "o", not squares....

@WeatherGod
Copy link
Member

That is because plot() doesn't use that parameter to determine the default
marker. It is called "lines".marker because it is specifying a default
marker for other lines like lines for polygons and such. The specification
for markers in plot() comes from the parameters to its function call. It
never checks the rcParams. Perhaps it should be better documented because
I am not exactly sure when it would apply, I just know that it doesn't
apply for plot().

By the way, single quotes are perfectly valid and are used elsewhere in the
rc file. I don't see double-quotes used anywhere in the rc file. It is an
ini-style configuration file, not a python script. Where would you put a
notice about quotations?

Ben Root

On Sat, Oct 18, 2014 at 12:26 PM, kfiz notifications@github.com wrote:

Hmm. Well specifying ".", results in "o" not ".", on my machine.
I also tried:
lines.marker : s # the default marker
Which also results in circles, i.e. "o", not squares....


Reply to this email directly or view it on GitHub
#3670 (comment)
.

@kfiz
Copy link
Author

kfiz commented Oct 19, 2014

Ok, if these settings don't apply to plot, scatter and such, then this obviously explains the behaviour I observed. I agree, one should state clearly, to what types of plots/graphics the settings in matplotlibrc apply.

@tacaswell
Copy link
Member

lines.marker does apply to plot:

In [2]: plt.plot(range(15))
Out[4]: [<matplotlib.lines.Line2D at 0x7fcd86258790>]

with

lines.marker      : *    # the default marker

in my matplolibrc file.

The default is read in https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/lines.py#L296

so

@WeatherGod
Copy link
Member

Sigh... Gotta love how many levels deep we evaluate these rcParams!

@tacaswell
Copy link
Member

I would argue that the deeper the better with these.

@kfiz
Copy link
Author

kfiz commented Oct 19, 2014

Now I'm really confused.
matplotlibrc:
lines.marker : * # the default marker
But:
In [2]: plot(range(15))
throws:
ValueError: Unrecognized marker style *
Is this local to my machine?

@kfiz
Copy link
Author

kfiz commented Oct 19, 2014

Sorry, checked again. The above example works on my machine. Had a typo in matplotlibrc.

@story645
Copy link
Member

story645 commented Jun 1, 2016

There are no quotes in the rcparams and stylesheet docs, so can this issue be closed?

@efiring
Copy link
Member

efiring commented Jun 1, 2016

It's a bit more complicated than that. There are occasional cases of quotes such as in the cycler specification and all of the animation parameters. I suspect we are stuck with relying on the examples, as you suggest; we can't just add a line somewhere saying "don't put quotes around values in the matplotlibrc file" because there are exceptions.
@story645, would you like to have a look at the parsing code to see if you can figure out when quotes are required, optional, or forbidden?

@story645 story645 self-assigned this Jun 1, 2016
@NelleV
Copy link
Member

NelleV commented Sep 30, 2016

Hi @story645
You've assigned yourself to this issue. Do you plan on moving forward with this? Else, i'll tag this issue as "machine shop" compatible.

@story645 story645 removed their assignment Oct 2, 2016
@story645
Copy link
Member

story645 commented Oct 2, 2016

Sorry, go ahead, totally forgot to follow up. Also what do you mean by machine shop?

@story645 story645 self-assigned this Nov 6, 2019
@story645 story645 modified the milestones: unassigned, needs sorting Oct 6, 2022
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Oct 9, 2023
@story645 story645 added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Oct 9, 2023
@story645
Copy link
Member

story645 commented Oct 19, 2023

So uh finally got back to this, and I think it may make more sense to ensure that all the validation functions try to support quoted enteries rather than to document which ones do and don't. That's because, as of now, we have about 47 functions (give or take parameterizations and listifyers) for about 317 rcParams. If there's support, I'd like to repurpose the RcParams project to track work checking each function & follow up prs to add support as needed.

Basically I'm thinking the work involved is:

  1. choose validation method
  2. find validation test method in test_rcsetup
  3. add a quoted test case
  4. if test case fails, add support for quoted value
  5. alert maintainer to PR so we can add to project & update table
validator function # rcparams rcParams
0 validate_bool 71 backend_fallback, interactive, webagg.open_in_browser, lines.antialiased, lines.scale_dashes, pcolormesh.snap, patch.force_edgecolor, patch.antialiased, boxplot.notch, boxplot.vertical, boxplot.patchartist, boxplot.showmeans, boxplot.showcaps, boxplot.showbox, boxplot.showfliers, boxplot.meanline, text.usetex, text.antialiased, text.parse_math, image.resample, image.composite_image, contour.corner_mask, axes.spines.left, axes.spines.right, axes.spines.bottom, axes.spines.top, axes.grid, axes.formatter.use_locale, axes.formatter.use_mathtext, axes.formatter.useoffset, axes.unicode_minus, polaraxes.grid, axes3d.grid, axes3d.automargin, 'date.interval_multiples', legend.fancybox, legend.shadow, legend.frameon, xtick.top, xtick.bottom, xtick.labeltop, xtick.labelbottom, xtick.minor.visible, xtick.minor.top, xtick.minor.bottom, xtick.major.top, xtick.major.bottom, ytick.left, ytick.right, ytick.labelleft, ytick.labelright, ytick.minor.visible, ytick.minor.left, ytick.minor.right, ytick.major.left, ytick.major.right, figure.frameon, figure.autolayout, figure.raise_window, figure.constrained_layout.use, savefig.transparent, tk.window_focus, ps.useafm, pdf.inheritcolor, pdf.use14corefonts, pgf.rcfonts, svg.image_inline, docstring.hardcopy, path.simplify, path.snap, _internal.classic_mode
1 validate_float 54 lines.linewidth, lines.markeredgewidth, lines.markersize, patch.linewidth, hatch.linewidth, boxplot.flierprops.markeredgewidth, boxplot.flierprops.markersize, boxplot.flierprops.linewidth, boxplot.boxprops.linewidth, boxplot.whiskerprops.linewidth, boxplot.capprops.linewidth, boxplot.medianprops.linewidth, boxplot.meanprops.markersize, boxplot.meanprops.linewidth, font.size, errorbar.capsize, axes.linewidth, axes.titlepad, axes.labelpad, legend.markerscale, legend.borderpad, legend.labelspacing, legend.handlelength, legend.handleheight, legend.handletextpad, legend.borderaxespad, legend.columnspacing, xtick.major.size, xtick.minor.size, xtick.major.width, xtick.minor.width, xtick.major.pad, xtick.minor.pad, ytick.major.size, ytick.minor.size, ytick.major.width, ytick.minor.width, ytick.major.pad, ytick.minor.pad, grid.linewidth, grid.alpha, figure.dpi, figure.subplot.left, figure.subplot.right, figure.subplot.bottom, figure.subplot.top, figure.subplot.wspace, figure.subplot.hspace, figure.constrained_layout.hspace, figure.constrained_layout.wspace, figure.constrained_layout.h_pad, figure.constrained_layout.w_pad, savefig.pad_inches, animation.embed_limit
2 validate_color 25 lines.color, patch.edgecolor, patch.facecolor, hatch.color, boxplot.flierprops.color, boxplot.flierprops.markeredgecolor, boxplot.boxprops.color, boxplot.whiskerprops.color, boxplot.capprops.color, boxplot.medianprops.color, boxplot.meanprops.color, boxplot.meanprops.markerfacecolor, boxplot.meanprops.markeredgecolor, text.color, axes.facecolor, axes.edgecolor, axes.labelcolor, axes3d.xaxis.panecolor, axes3d.yaxis.panecolor, axes3d.zaxis.panecolor, xtick.color, ytick.color, grid.color, figure.facecolor, figure.edgecolor
3 validate_stringlist 24 figure.hooks, font.family, font.serif, font.sans-serif, font.cursive, font.fantasy, font.monospace, keymap.fullscreen, keymap.home, keymap.back, keymap.forward, keymap.pan, keymap.zoom, keymap.save, keymap.quit, keymap.quit_all, keymap.grid, keymap.grid_minor, keymap.yscale, keymap.xscale, keymap.help, keymap.copy, animation.ffmpeg_args, animation.convert_args
4 ValidateInStrings 23 pcolor.shading, text.hinting, mathtext.fontset, mathtext.default, image.origin, contour.algorithm, xaxis.labellocation, yaxis.labellocation, axes.titlelocation, axes.grid.which, axes.grid.axis, axes.autolimit_mode, 'date.converter', xtick.direction, xtick.alignment, ytick.direction, ytick.alignment, macosx.window_mode, 'savefig.orientation', pgf.texsystem, svg.fonttype, animation.html, animation.frame_format
5 validate_string 22 timezone, webagg.address, lines.marker, boxplot.flierprops.marker, boxplot.meanprops.marker, font.style, font.variant, text.latex.preamble, image.interpolation, scatter.marker, scatter.edgecolors, date.autoformatter.year, date.autoformatter.month, date.autoformatter.day, date.autoformatter.hour, date.autoformatter.minute, date.autoformatter.second, date.autoformatter.microsecond, savefig.format, pgf.preamble, animation.writer, animation.codec
6 validate_int 14 webagg.port, webagg.port_retries, text.hinting_factor, text.kerning_factor, image.lut, axes.formatter.min_exponent, axes.formatter.offset_threshold, legend.numpoints, legend.scatterpoints, figure.max_open_warning, ps.distiller.res, pdf.compression, agg.path.chunksize, animation.bitrate
7 _validate_linestyle 9 lines.linestyle, boxplot.flierprops.linestyle, boxplot.boxprops.linestyle, boxplot.whiskerprops.linestyle, boxplot.capprops.linestyle, boxplot.medianprops.linestyle, boxplot.meanprops.linestyle, contour.negative_linestyle, grid.linestyle
8 validate_fontsize 7 axes.titlesize, axes.labelsize, legend.fontsize, xtick.labelsize, ytick.labelsize, figure.titlesize, figure.labelsize
9 validate_font_properties 7 mathtext.cal, mathtext.rm, mathtext.tt, mathtext.it, mathtext.bf, mathtext.bfit, mathtext.sf
10 validate_color_or_auto 6 lines.markerfacecolor, lines.markeredgecolor, boxplot.flierprops.markerfacecolor, axes.titlecolor, 'savefig.facecolor', 'savefig.edgecolor'
11 validate_fontweight 5 font.weight, axes.titleweight, axes.labelweight, figure.titleweight, figure.labelweight
12 validate_color_or_inherit 4 legend.facecolor, legend.edgecolor, xtick.labelcolor, ytick.labelcolor
13 _validate_greaterthan_minushalf 3 axes.xmargin, axes.ymargin, axes.zmargin
14 _validate_pathlike 3 savefig.directory, animation.ffmpeg_path, animation.convert_path
15 validate_float_or_None 3 contour.linewidth, axes.titley, legend.framealpha
16 validate_floatlist 3 lines.dashed_pattern, lines.dashdot_pattern, lines.dotted_pattern
17 JoinStyle 2 lines.dash_joinstyle, lines.solid_joinstyle
18 validate_fonttype 2 ps.fonttype, pdf.fonttype
19 _validate_minor_tick_ndivs 2 xtick.minor.ndivs, ytick.minor.ndivs
20 CapStyle 2 lines.dash_capstyle, lines.solid_capstyle
21 validate_int_or_None 1 boxplot.bootstrap
22 _validate_mathtext_fallback 1 mathtext.fallback
23 _validate_greaterequal0_lessequal1 1 path.simplify_threshold
24 validate_anylist 1 path.effects
25 validate_whiskers 1 boxplot.whiskers
26 _listify_validator(validate_float, n=2) 1 figure.figsize
27 _validate_legend_loc 1 legend.loc
28 validate_dpi 1 'savefig.dpi'
29 validate_bbox 1 savefig.bbox
30 _validate_papersize 1 ps.papersize
31 _validate_cmap 1 image.cmap
32 validate_axisbelow 1 axes.axisbelow
33 validate_fillstyle 1 markers.fillstyle
34 validate_fontstretch 1 font.stretch
35 validate_fontsize_None 1 legend.title_fontsize
36 _validate_toolbar 1 toolbar
37 validate_cycler 1 axes.prop_cycle
38 validate_hist_bins 1 hist.bins
39 _listify_validator(validate_int, n=2) 1 axes.formatter.limits
40 validate_sketch 1 path.sketch
41 _validate_color_or_linecolor 1 legend.labelcolor
42 _validate_date 1 date.epoch
43 validate_backend 1 backend
44 validate_ps_distiller 1 ps.usedistiller
45 validate_aspect 1 image.aspect
46 validate_string_or_None 1 svg.hashsalt

@story645
Copy link
Member

Discussed on call and @ksunden pointed out that the everything string approach would create ambiguity for colors, and @QuLogic mentioned @chahak13's work may help in building a directive to improve documentation. The conclusion was that one path forward is to allow '' for the subset of validation functions that take strings where allowing quotes would not create ambiguity.

Particularly allowing for quotes in the following should handle most use cases:

  • ValidateInStrings
  • validate_stringlist
  • validate_string

@timhoffm
Copy link
Member

timhoffm commented Oct 20, 2023

On a side-note: These are the burdens of having a custom file format. Any type-aware format (YAML, TOML, python files, ...) would defer these complications to the format specification/parser and set clear expectations for the user. It would in principle not be difficult do migrate to another format. The major obstacle will be argee on one of them).

@story645
Copy link
Member

story645 commented Oct 20, 2023

Any type-aware format (YAML, TOML, python files, ...)

I went through all the trouble of #26854 & the like six PRs it spawned to avoid Python files 😭
But also, more seriously, I know we don't use MEPs anymore but I think the .css like approach proposed in MEP 26 would be the most natural transition from what we're already doing to a system that's more flexible and has better type support. I also think MEP 26 can be well scoped if we want to make it a paid project, either GSOC or SDG.

@anntzer
Copy link
Contributor

anntzer commented Nov 15, 2023

As I already suggested elsewhere, another possibility would be to keep supporting key: value (for backcompat) but additionally support key = <python literal>, where all strings must be quoted (and where the literal can be parsed with ast.literal_eval), and move all the documentation to recommend the latter. This way there's no ambiguity, and I don't think asking users to quote their strings is overly painful... (plus, they can keep the old format if they want)

@timhoffm
Copy link
Member

timhoffm commented Nov 15, 2023

While unambiguous in definition, I'm afraid that'd be still a major source of confusion - users typically don't use this often and it's hard to remember whether it was key: value or key: <python literal>.

I have a strong preference for any standard format. That way we get rid of all parsing complications, and users don't have to learn a custom syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation keep Items to be ignored by the “Stale” Github Action topic: rcparams
Projects
None yet
Development

No branches or pull requests

8 participants