GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Using legend with a stem plot misbehave · Issue #185 · matplotlib/matplotlib

Using legend with a stem plot misbehave #185

New issue
Copy link
New issue
Copy link
Closed
Closed
Using legend with a stem plot misbehave#185
Copy link

Description

@ddale
ddale
opened on Jun 20, 2011
Issue body actions

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

    @leejjoon
    leejjoon
    on Jul 21, 2011
    Contributor
    More actions

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

  2. leejjoon
    closed this as completedon Jul 21, 2011
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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.