create a 3D pie chart
Drop files here
or click to upload
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plot_pie_chart(sizes, labels):
# Create a 3D pie chart
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
theta = np.linspace(0, 2 * np.pi, len(sizes))
x = np.cos(theta) * sizes
y = np.sin(theta) * sizes
z = np.zeros(len(sizes))
ax.bar(x, y, zs=z, zdir='z', alpha=0.8)
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
ax.view_init(30, 200)
# Draw labels
for i in range(len(sizes)):
ax.text(x[i], y[i], sizes[i], labels[i], color='black', ha='center', va='center')
return fig
st.title('3D Pie Chart')
sizes = [10, 20, 30, 40]
labels = ['A', 'B', 'C', 'D']
fig = plot_pie_chart(sizes, labels)
plt.title('3D Pie Chart Example')
st.pyplot(fig)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?