FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Using legend with a stem plot misbehave · Issue #185 · matplotlib/matplotlib · GitHub

Repository navigation

Using legend with a stem plot misbehave #185

Closed

Description

Original report at SourceForge, opened Thu Jan 6 10:02:52 2011

The legend of the stem plots doesn't behave as expected. The following code illustrate the problem:

import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y1 = [1, 2, 3, 4, 5]
y2 = [5, 4, 3, 2, 1]

plt.subplot(211)
plt.plot(x, y1, 'rx-')
plt.plot(x, y2, 'bx-')
plt.legend(('a', 'b'))

plt.subplot(212)
plt.stem(x, y1, 'r')
plt.stem(x,y2, 'b')
plt.legend(('a', 'b'))

plt.savefig('stem_legend.png')

plt.show()

I expect the legend for the stem case to look similar to the plot case, however, for the stem, I get the two labels of the legend
associated with the first stem command: 'a' linked to the marker and 'b' linked to the stem line.

SourceForge Comments

On Thu Jan 6 10:08:29 2011, None wrote:

I think the right behavior should be similar to what Matlab does. I attached a file with the Matlab plot corresponding to the equivalent Matplotlib code.

SourceForge History

  • On Thu Jan 6 10:06:18 2011, by None: File Added: 397833: stem_legend_matlab.png
  • On Thu Jan 6 10:02:52 2011, by None: File Added: 397831: stem_legend.png

Activity

  1. leejjoon commented on Jul 21, 2011

    Contributor

    This issue has been addressed by #146, the handle representation could be different though (I cannot access the original attached figures).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL