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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:42:55+00:00 2026-05-23T01:42:55+00:00

I need a legend for a code which generates data from a dict. I

  • 0

I need a legend for a code which generates data from a dict. I don’t know how much keys exist in the dict is there a way to do ‘dynamic’ a legend on this?

import matplotlib.pyplot as plt

for host in d.keys():
  plt.plot(range(100),d[host])

plt.show()
  • 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-23T01:42:56+00:00Added an answer on May 23, 2026 at 1:42 am

    If I understand you, then sure: you simply need to turn the key into a label somehow, even if it’s as simple as calling str on it.

    import matplotlib.pyplot as plt
    import numpy
    
    x = numpy.arange(10.)
    d = dict((i, numpy.sin(x+i)) for i in range(5))
    
    for k in sorted(d):  # sort purely to make deterministic
        plt.plot(x,d[k],label=str(k))
    
    plt.legend(loc=2)
    plt.draw()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to hide every second/third/forth item from the legend. IS there a way
I need to import data from an FTP server. the filenames on the FTP
Need a way to allow sorting except for last item with in a list.
Need to insert selected text on the page into textarea. There must be some
I'm generating tables based on some fields from database and I need to specify
I have filled splitcontainer. legend for image: SplitContainer ListViews Spliter Need: blue lines show
My code right now has O(N) insertion time, and O(1) removal time. I need
I wrote the code below to output the figure but still need to figure
In the MS Chart control (which they bought from Dundas), I have three series
Let me know if I have to make this more concise, if you don't

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.