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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:57:49+00:00 2026-05-30T12:57:49+00:00

I am trying to create a 3D bar histogram in Python using bar3d() in

  • 0

I am trying to create a 3D bar histogram in Python using bar3d() in Matplotlib.

I have got to the point where I can display my histogram on the screen after passing it some data, but I am stuck on the following:

  1. Displaying axes labels correctly (currently misses out final (or initial?) tick labels)
  2. Either making the ticks on each axis (e.g. that for ‘Mon’) either point to it’s corresponding blue bar, or position the tick label for between the major tick marks.
  3. Making the bars semi-transparent.

image of plot uploaded here

I have tried passing several different arguments to the ‘ax’ instance, but have not got anything to work despite and suspect I have misunderstood what to provide it with. I will be very grateful for any help on this at all.

Here is a sample of the code i’m working on:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

#from IPython.Shell import IPShellEmbed
#sh = IPShellEmbed()

data = np.array([
[0,1,0,2,0],
[0,3,0,2,0],
[6,1,1,7,0],
[0,5,0,2,9],
[0,1,0,4,0],
[9,1,3,4,2],
[0,0,2,1,3],
])

column_names = ['a','b','c','d','e']
row_names = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']

fig = plt.figure()
ax = Axes3D(fig)

lx= len(data[0])            # Work out matrix dimensions
ly= len(data[:,0])
xpos = np.arange(0,lx,1)    # Set up a mesh of positions
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.25, ypos+0.25)

xpos = xpos.flatten()   # Convert positions to 1D array
ypos = ypos.flatten()
zpos = np.zeros(lx*ly)

dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = data.flatten()

ax.bar3d(xpos,ypos,zpos, dx, dy, dz, color='b')

#sh()
ax.w_xaxis.set_ticklabels(column_names)
ax.w_yaxis.set_ticklabels(row_names)
ax.set_xlabel('Letter')
ax.set_ylabel('Day')
ax.set_zlabel('Occurrence')

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-30T12:57:50+00:00Added an answer on May 30, 2026 at 12:57 pm

    To make the bars semi-transparent, you just have to use the alpha parameter. alpha=0 means 100% transparent, while alpha=1 (the default) means 0% transparent.

    Try this, it will work out to make the bars semi-transparent:

    ax.bar3d(xpos,ypos,zpos, dx, dy, dz, color='b', alpha=0.5)
    

    Regarding the ticks location, you can do it using something like this (the first list on plt.xticks or plt.yticks contains the “values” where do you want to locate the ticks, and the second list contains what you actually want to call the ticks):

    #ax.w_xaxis.set_ticklabels(column_names)
    #ax.w_yaxis.set_ticklabels(row_names)
    
    ticksx = np.arange(0.5, 5, 1)
    plt.xticks(ticksx, column_names)
    
    ticksy = np.arange(0.6, 7, 1)
    plt.yticks(ticksy, row_names)
    

    In the end, I get this figure:
    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 am trying to create a download progress bar in python using the urllib2
I'm trying to create a horizontal 100% stacked bar graph using HTML and CSS.
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying to create a menu bar for my application. I have created
I've been trying to create a full screen view. I plan on using core
I'm trying to create a very simple bar chart using the results of a
I am trying to create a bar graph using the matplot library but I
i am trying to create a menu bar using jquery. I am using the
I am trying to create a basic navigation bar using an unordered list, but
I am trying to create bar graphs of letter frequency in Python. I thought

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.