Python matplotlib -> 3D bar plot -> adjusting tick label position, transparent bars

后端 未结 1 627
忘掉有多难
忘掉有多难 2021-02-06 13:03

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 s

相关标签:
1条回答
  • 2021-02-06 13:37

    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 讨论(0)
提交回复
热议问题