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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:22:15+00:00 2026-06-11T13:22:15+00:00

i would like to plot my data in such a fashion, that bars are

  • 0

i would like to plot my data in such a fashion, that bars are grouped up?Something like this:

example

my code looks like this so far:

data = NP.genfromtxt('newfile',unpack=True,names=True,dtype=None)
for i in sample:
 mask = data['name'==sample]
 ax2.bar(pos-0.5,(data['data']*100,label="samples", color="lightblue")

This created several graphs instead of a combined one, though. How do i convert this into a grafic looking like the one i presented above?

  • 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-11T13:22:16+00:00Added an answer on June 11, 2026 at 1:22 pm

    Without having all the code listed, I had to make some assumptions about the data and about what you wanted. Thus, I haven’t tested this code with actual data. I have tried to document my assumptions carefully in the code below. If you have problems with what I’ve posted, perhaps you could post the text file mentioned in the first line of your code.

    # Assume data is a record array
    data = NP.genfromtxt('newfile',unpack=True,names=True,dtype=None)
    
    # Assume 'sample' is a column in the data
    sample = NP.unique(data['name'])
    num_items = len(sample)
    ind = NP.arange(sample)
    
    # The margin can be increased to add more space between the groups of data
    margin = 0.05
    width = (1.-2.*margin)/num_items
    
    # This list will make each sample data set a different color
    # It must be AT LEAST as long as the number of samples
    # If not, the extra data won't be plotted
    colorList = ['red', 'blue', 'black']
    if len(colorList) < num_items:
        print 'Warning: the number of samples exceeds the length of the color list.'
    
    f = plt.figure()
    
    # Assumed the color was supposed to vary with each data set, so I added a list
    for s, color in zip(enumerate(sample), colorList):
        num, i = s
        print "plotting: ", i
        # Assumed you want to plot a separate set of bars for each sample, so I changed the mask to 'name'==i
        mask = data['name'==i]
        # The position of the xdata must be calculated for each of the sample data series
        xdata = ind+margin+(num*width)
        # Assumed you wanted to plot the 'data' column where mask is true and then multiply by 100
        # Also assumed the label and color were supposed to vary with each data set
        plt.bar(xdata, data['data'][mask]*100, width, label=i, color=color)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make a plot with ggplot that looks very close to
I'm trying to plot data in matplotlib. I would like to hide the upper
I have a large real 1-d data set called r. I would like plot:
I would like to make a log-probability plot for my data. I looked up
I have a dataframe like this: block plot date data 1 1 aug 11.95171507
I have some US demographic and firmographic data. I would like to plot zipcode
I would like to create 10 plots that have different data, but the same
I have multiple vectors of varying lengths that I would like to plot next
I have a time series(a csv file) data that looks like below. Each observation
I am using the MSChart Control to plot some data but I would like

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.