6

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?

Mike S.
  • 61
  • 1
  • 2
  • I don't have access to test right now, but [this answer](http://stackoverflow.com/a/8409110/812786) may be helpful. – user812786 Oct 05 '15 at 16:26
  • Thanks for the fast answer but the link is not helpful. The problem is the combination of subplot and stem. – Mike S. Oct 05 '15 at 18:02

2 Answers2

11

Here is my solution:

 markerline, stemlines, baseline = plt.stem(x, y)
 plt.setp(stemlines, 'linewidth', 3)
Louic
  • 2,403
  • 3
  • 19
  • 34
0

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")
ramsluk
  • 104
  • 7