I am new-ish to Matplotlib.
I made a stem plot (aka lollipop) using Python/Matplotlib. These kinds of plots have style settings: linefmt
, markerfmt
, basefmt
.
For instance, I can change the color of the baseline like so:
plt.stem(X, Y, basefmt="m")
I'd like to see the points and the stems, but I don't want to see the actual baseline. What command/format code do I need to "hide" the baseline? Or am I approaching this wrong?
你可以在一行中完成所有工作:
plt.stem(X, Y, basefmt=" ")
An alternative to brian_o's answer is to set the visible
property to False
:
(markerline, stemlines, baseline) = plt.stem(X, Y)
plt.setp(baseline, visible=False)
It looks like stem
returns a triplet, the third value of which is the baseline object. It can then be manipulated with a setp
command.
m,n,baseline = plt.stem(X, Y, basefmt="m")
plt.setp(baseline, 'linewidth', 0)
The code seems to work, but in my opinion it's ultra hacky. Can anyone with a better understanding of default args or keywords do better?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.