Mike S.
Mike S.

Reputation: 71

matplotlib: change stem plot linewidth

i have image containing 4 subplots:

    #!/usr/bin/env python3
    import matplotlib.pyplot as plt
    f, axarr = plt.subplots(2, 2) 
    axarr[0,1].stem([1,3,-4],linefmt='b-', markerfmt='bs', basefmt='k-')
    plt.show()

I want to change the linewidth of one plot (stem plot). Is there an easy way to do this?

Upvotes: 7

Views: 7852

Answers (2)

ramsluk
ramsluk

Reputation: 124

The returned stemlines are a matplotlib LineCollection and you can change their format like so:

stem = plt.stem(x,y)
# stem[1] change stemlines
stem[1].set_linewidth(5)
stem[1].set_linestyles("dashed")

Upvotes: 1

Louic
Louic

Reputation: 2603

Here is my solution:

 markerline, stemlines, baseline = plt.stem(x, y)
 plt.setp(stemlines, 'linewidth', 3)

Upvotes: 12

Related Questions