Reputation: 2157
I have several different regions that measure the 2-d spatial event of something given a condition. The condition is encoded with the color of the region. The regions in general are polygons (even though I've plotted circles) and can have holes in them, as in:
To increase clarity of visualization, I have been requested to turn this into what has been called a "wedding cake plot", where each region has a vertical offset from each other, with vertical sides around each region. Something kind of like the following Paint image:
How to go about doing this with Matplotlib, or some other Python plotting package?
Upvotes: 1
Views: 132
Reputation: 35155
The plotly library has a function to draw a funnel, so you can use that instead. The following is a graph from the official reference, with some modifications to make it look the way you want.
from plotly import graph_objects as go
x_sorted = sorted([39, 27.4, 20.6, 11, 2])
y_sorted = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"]
fig = go.Figure(go.Funnel(
y = y_sorted[::-1],
x = x_sorted,
marker={'color':['black','yellow','green','blue','red']})
)
fig.show()
Upvotes: 0
Reputation: 150745
You can do something with plot_surface
like this:
# sample data
data = np.zeros((20,24))
data[2:18, 2:18] = 1
data[4:16, 4:16] = 2
data[6:14,6:14] = 3
data[8:12,8:12] = 2
# 2D view
plt.imshow(data, cmap='Reds')
# mesh
X,Y=np.mgrid[0:data.shape[0], 0:data.shape[1]]
# plot
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
surf = ax.plot_surface(X, Y, data, cmap='hot',
linewidth=0, antialiased=False)
Output:
Note You would need to hierarchically label your data correctly.
Upvotes: 2