You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If that doesn't work, please post on discourse.matplotlib.org with more details about what you're doing.
That being said, I'm conflicted on natively supporting cmap for bar since it's unclear which value folks would want to colormap - how to decide if it's height, position, or a third value seperate from either . Though maybe it should be implemented like scatter where it's applied to data that's passed into the color keyword?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from matplotlib import style
style.use('ggplot')
# setup the figure and axes
fig = plt.figure(figsize=(8, 3))
ax1 = fig.add_subplot(111, projection='3d')
# fake data
_x = np.array([1,2,3,4])
_y = np.array([1,2,3,4,5])
_xx, _yy = np.meshgrid(_x, _y)
x, y = _xx.ravel(), _yy.ravel()
top = x + y
bottom = np.zeros_like(top)
width = depth = 1
norm = plt.Normalize(-1,1)
norm_values = norm(top)
map_vir = plt.cm.get_cmap(name='plasma')
colors = map_vir(norm_values)
ax1.bar3d(x, y, bottom, 0.5, 0.5, top,color=colors,shade=True)
plt.show()
I'm working on a project, like a car, it's has attributes as [speed, press,statistics_value] , the data value will be [20, 3000, 23.6]...... i want to draw a 3d bar to figure the datas. if statistics_value <10 ,the color:'r', if statistics >50, the color:'dark red'. this is my purpose.
Like scatter which give the data to color keyword is simple way, and that's what i want. but 4 lines code in matlab....
Problem
https://ww2.mathworks.cn/help/matlab/creating_plots/color-3-d-bars-by-height-1.html
how can i draw 3d bars gradient in matplotlib? the bar3d(color, cmap) is not working.
pls help.
Proposed solution
No response
The text was updated successfully, but these errors were encountered: