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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:05:30+00:00 2026-06-15T07:05:30+00:00

I have this plot: data = {‘User 1’: [1,2,3], ‘User 2’: [5, 8, 10],

  • 0

I have this plot:

data = {'User 1': [1,2,3], 'User 2': [5, 8, 10], 'User 3': [80, 75, 100], 'User 4': [65, 80, 45]}
characteristics = [('commits', 'r'), ('intended h', 'g'), ('actual h', 'b')]

n_bars = (len(characteristics)+1)*len(data)

fig = plt.figure(figsize=(5,5))
ax = fig.add_axes([0.15, 0.15, 0.65, 0.7])
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.set_yticklabels(data.keys())
ax.set_yticks(np.arange(len(characteristics)/2, n_bars, len(data)))

pers_id = 0
bar_id = 0

for name, data in data.iteritems():
    for char_id, characteristic in enumerate(characteristics):
        ax.barh(bar_id, data[char_id], facecolor=characteristic[1])
        bar_id = bar_id + 1
    ax.barh(bar_id, 100, facecolor='white', linewidth=0)
    bar_id += 1
    pers_id += 1

plt.savefig('perf.png')
plt.show()

enter image description here

The only big feature I still need is to add a legend on the top right, with the labels indicated at characteristics[i][0] and the colors from characteristics[i][0].

How would I get this working?

  • 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-06-15T07:05:31+00:00Added an answer on June 15, 2026 at 7:05 am

    pandas has some data structures and methods to handle and plot such data:

    In [89]: import pandas as pd
    
    In [90]: df = pd.DataFrame(data).T
    
    In [91]: df.columns = [c[0] for c in characteristics]
    
    In [92]: df
    Out[92]: 
            commits  intended h  actual h
    User 1        1           2         3
    User 2        5           8        10
    User 3       80          75       100
    User 4       65          80        45
    
    In [93]: colors = [c[1] for c in characteristics]
    
    In [94]: df.sort_index(ascending=False).plot(kind='barh', color=colors)
    

    pandas_barh

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

Sidebar

Related Questions

I have a graph library that I use to plot some data. This data
I have a data like this. Is there any way to smoothen my plot
I have a dataframe like this: block plot date data 1 1 aug 11.95171507
i have this piece of code. To explain: The user inputs initcores data and
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have found this answer really useful. It helps me plot network/graphs and select
With this approach. I have a line plot graph. I want to plot 'two'
I have a list to which I append Axes3D plots. Like this: self.myList.append(self.axes.plot(xValues, yValues,
I have data of this format: 2011-06-22 22:33:19 23 15 2011-06-23 09:46:13 12 79
So i have this data x 1.0423 2.8249 3.2016 2.0851 1.0299 4.7397 0.4104 0.5285

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.