Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf34aed0

Browse files
committed
MNT: simplify identifying valid style codes
If the second arguement to `plot` is both in data and a valid style codewarn the user.
1 parent5fbe4b0 commitf34aed0

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,15 @@ def _plot_args_replacer(args, data):
5959
return ["y","c"]
6060
# it's data, but could be a color code like 'ro' or 'b--'
6161
# -> warn the user in that case...
62-
arg2=args[1]
63-
ifis_string_like(arg2)andlen(arg2)<=3:
64-
# all possible linestyles and color codes -> see doc of plot
65-
reserved_ls= ["-","--","-.",":",".",",","o","v","^","<",
66-
">","1","2","3","4","s","p","*","h","H",
67-
"+","x","D","d","|","_"]
68-
reserved_cc= ["b","r","c","m","y","k","w"]
69-
# remove the line style part
70-
forlsinreserved_ls:
71-
iflsinarg2:
72-
arg2=arg2.replace(ls,'')
73-
continue
74-
# can now only be a color code...
75-
ifarg2inreserved_cc:
76-
importwarnings
77-
msg="Second argument is ambiguous: could be a color spec " \
78-
"but is in data. Using as data.\nEither rename the " \
79-
"entry in data or use three arguments to plot."
80-
warnings.warn(msg,RuntimeWarning,stacklevel=3)
62+
try:
63+
_process_plot_format(args[1])
64+
exceptValueError:
65+
pass
66+
else:
67+
msg="Second argument is ambiguous: could be a color spec " \
68+
"but is in data. Using as data.\nEither rename the " \
69+
"entry in data or use three arguments to plot."
70+
warnings.warn(msg,RuntimeWarning,stacklevel=3)
8171
return ["x","y"]
8272
eliflen(args)==3:
8373
return ["x","y","c"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp