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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:33:45+00:00 2026-06-16T18:33:45+00:00

This question is somewhat related to Visually separating bar chart clusters in pandas I

  • 0

This question is somewhat related to Visually separating bar chart clusters in pandas

I am reading and plotting the tmp.csv file:

pol1 pol2 pol3
perim 0.54 0.64 0.40
mst 0.08 0.12 0.12
treeadd 0.25 0.34 0.35
health 0.14 0.17 0.17
bisort 0.48 0.56 0.56
em3d 0.14 0.17 0.17

g721d 1.41 2.58 2.58
mesa 1.16 1.8 1.8
epic 1.82 2.43 2.43
jpege 1.18 1.68 1.68

gzip 1.15 1.43 1.45
vpr 0.19 0.24 0.24
gcc 0.82 1.11 1.15
mcf 0.05 0.05 0.05
crafty 0.67 1.17 1.17

with:

#!/usr/bin/env python

from pandas import *
import matplotlib.pyplot as plt
from numpy import zeros

# Create original dataframe
df = read_csv('tmp.csv',sep='\s')

print df

df.plot(kind='bar')
plt.show()

and I get:

         pol1  pol2  pol3
perim    0.54  0.64  0.40
mst      0.08  0.12  0.12
treeadd  0.25  0.34  0.35
health   0.14  0.17  0.17
bisort   0.48  0.56  0.56
em3d     0.14  0.17  0.17
nan       NaN   NaN   NaN
g721d    1.41  2.58  2.58
mesa     1.16  1.80  1.80
epic     1.82  2.43  2.43
jpege    1.18  1.68  1.68
nan       NaN   NaN   NaN
gzip     1.15  1.43  1.45
vpr      0.19  0.24  0.24
gcc      0.82  1.11  1.15
mcf      0.05  0.05  0.05
crafty   0.67  1.17  1.17

and:

enter image description here

Note the separation of the clusters with the empty lines. This is the effect I want.
Is there a way to replace the ‘nan’ label with “” in the x-axis?

I tried:
df.rename(index={‘nan’: “”})

However there is an assertion failing

assert(new_axis.is_unique)

Probably because there are multiple ‘nan’ indexing the df. Ideas?

-Thanks

  • 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-16T18:33:45+00:00Added an answer on June 16, 2026 at 6:33 pm

    Instead of modifying the DataFrame, perhaps just change the matplotlib xtick labels:

    import pandas as pd
    import matplotlib.pyplot as plt
    
    df = pd.read_csv('tmp.csv', sep = '\s')
    df.plot(kind='bar')
    locs, labels = plt.xticks()
    plt.xticks(locs, [d if d==d else '' for d in df.index], rotation = 25)
    plt.show()
    

    enter image description here

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

Sidebar

Related Questions

This question is related somewhat to the one i asked HERE . Now, i
This is somewhat related to the question posed in this question but I'm trying
Somewhat related to this question , but in the absence of any answer about
This question is somewhat related to Handling a timeout in EJB3 without using threads
Although somewhat related to this question , I have what I think is a
My question is somewhat related to this thread: How to avoid Initialization of web
My question is somewhat related to this answer - https://stackoverflow.com/a/3458299/1635958 . I am working
This is somewhat related to another question I've asked but I figure why not
(This question might be somewhat related to pthread_exit in signal handler causes segmentation fault
This is somewhat related to this question : I have a table with a

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.