Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 227619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:36:49+00:00 2026-05-11T19:36:49+00:00

I have datapoints of different classes which I want to visualize. Here is the

  • 0

I have datapoints of different classes which I want to visualize. Here is the image that I get: https://i.stack.imgur.com/qwCLC.jpg

There are 3000 datapoints of 10 classes, 300 each. They are concatenated in a single array d over whose chunks I iterate. The labels are given in labels.

pylab.clf()
colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
for l, c  in zip(labels, colors):
  start, stop = i * 300, (i + 1) * 300
  pylab.plot(d[0, start:stop], d[1, start:stop], c, label=l)

pylab.legend(loc='lower left')
pylab.show()

Has anyone a clue why my legend is screwed up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:36:49+00:00Added an answer on May 11, 2026 at 7:36 pm

    It would help to have a self-contained example, possibly with made-up data, so people can run it right away. Here’s a self-contained example modified from what you posted that works fine for me in ipython -pylab, with a recent svn revision of Matplotlib; I think some legend-related bugs have been fixed recently.

    colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
    labels = 'one two three four five six seven eight nine ten'.split()
    x = linspace(0, 2*pi, 3000)
    d = (2+random((2,3000))) * c_[sin(x), cos(x)].T
    for i, l, c  in zip(range(10), labels, colors):
        start, stop = i * 300, (i + 1) * 300
        plot(d[0, start:stop], d[1, start:stop], c, label=l)
    legend(loc='lower left')
    show()
    

    And here’s what I get:

    example figure http://www.iki.fi/jks/tmp/legend.png

    Assuming the bug is related to the auto-legend feature, you might be able to work around it by being explicit about what you want in the legend:

    colors = (i + j for j in 'o<.' for i in 'bgrcmyk')
    labels = 'one two three four five six seven eight nine ten'.split()
    x = linspace(0, 2*pi, 3000)
    d = (2+random((2,3000))) * c_[sin(x), cos(x)].T
    lg = []
    for i, l, c  in zip(range(10), labels, colors):
        start, stop = i * 300, (i + 1) * 300
        handle = plot(d[0, start:stop], d[1, start:stop], c, label=l)
        lg.append(handle)
    legend(lg, labels, loc='lower left')
    show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of datapoints each of which belongs to a certain cluster
I want to create a massive TimeSeries object which will hold 1000 different financial
I have the following BBCode that I needed to parse [url=http://www.google.com]Google[/url] [url=http://www.google.com]Google[/url] What I
In my database I have tables that will grow at different speeds: fairly static
I have a set of data points in 3D space which apparently all fall
I have a set of X,Y data points (about 10k) that are easy to
I have a large number of data points which are two dimensional coordinates with
I have a plot that has data that runs into the area I'd like
I have a jQPlot line graph with three different series on it and am
Let's say I have a database for storing (numeric) datapoints. Datapoints are grouped together

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.