create a 3d pie chart for next dates: total peoples 1000 , romanian 800, hungarian 150, german 40 other 10
Drop files here
or click to upload
import matplotlib.pyplot as plt
import numpy as np
# Data for the pie chart
labels = ['Romanian', 'Hungarian', 'German', 'Other']
sizes = [800, 150, 40, 10]
colors = ['#ff9999','#66b3ff','#99ff99','#ffcc99']
# 3D Pie chart
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Creating a 3D pie chart manually
theta = np.linspace(0, 2 * np.pi, len(sizes), endpoint=False)
r = np.array(sizes) # Radius based on sizes
x = r * np.cos(theta)
# This will extend the pie charts depth in 3D
y = r * np.sin(theta)
# Making a 'fake' z coordinate for 3D aspect
z = np.zeros(len(sizes))
# Drawing bars to represent the pie chart in 3D
for i in range(len(sizes)):
ax.bar3d(x[i], y[i], z[i], dx=0.1, dy=0.1, dz=sizes[i], color=colors[i], alpha=0.7)
ax.set_title('3D Pie Chart Representation of People')
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')
ax.set_zlabel('Number of People')
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
# Show the chart in Streamlit
st.pyplot(fig)
st.write("Total People: 1000")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?