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 6357373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:09:08+00:00 2026-05-24T23:09:08+00:00

I have a plot with 6 different subplots. I iterate through a loop to

  • 0

I have a plot with 6 different subplots. I iterate through a loop to make each of the subplots and I want to add the legend for each subplot at this time too. So here is an easy example:

matrixSol = scipy.random.random((6,6,4))
print matrixSol
mylegend = ['10 Million','15 Million','1 Million','20 Million','25 Million','5 Million']

for k in range(6):
    print k
    xs = matrixSol[k,:,0]
    ys = matrixSol[k,:,1]
    zs = matrixSol[k,:,3]
    plt.subplot(2,3,k+1)
    plt.plot(ys, zs,'o', c=color[k], markersize=10)#marker = styles[k])
    #print mylegend[k]
    plt.legend((mylegend[k]),loc=2)
    plt.xlabel('X')
    plt.ylabel('Y (%)')
plt.show()

The problem is that I am getting a legend that picks only the first symbol of each member of the list, please see figure attached.
What is wrong with my code????
it is such a simple thing! thank you very much! any help will be appreciated!enter image description here

  • 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-24T23:09:08+00:00Added an answer on May 24, 2026 at 11:09 pm

    Use:

    plt.plot(ys, zs,'o', c=color[k], label=mylegend[k], markersize=10)
    plt.legend(loc=2)
    

    enter image description here

    alternatively, the solution already indicated by Chris Redford also works:

    plt.legend((mylegend[k],), loc=2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 6 vectors which I want to plot. How I can make each
I have a bunch of measurements over time and I want to plot them
I'm trying to make a plot with pylab/matplotlib, and I have two different sets
I want to plot several curves, each having a different length. So, I've placed
I have a plot (sample code pasted below) that I am trying to add
I have different types of QWidgets into a DockWindow: 1 Qwt plot 1 QWidget
I need to plot a dome (or half sphere) that have different radii. I
I have plots of 3-axis accelerometer time-series data (t,x,y,z) in separate subplots I'd like
I want to plot data from different data frames with ggplot. However, I'm having
Hi I have a need to create a Ternary Plot graph from 3 different

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.