kill it with the 3D scatter plot

100% awesome. The interactive 3D scatterplot is so killer. The key to making a great scatter plot is picking 3 axis points that can be correlated AND choosing a mean/average of a manageable number of features.

I love it! Hope you do too!

# Crea…


This content originally appeared on DEV Community and was authored by ANNA LAPUSHNER

Image description

Image description

100% awesome. The interactive 3D scatterplot is so killer. The key to making a great scatter plot is picking 3 axis points that can be correlated AND choosing a mean/average of a manageable number of features.

I love it! Hope you do too!

# Create a killer 3d scatter plot of company revenue. The axis points are the top 10 restaurants, average order and rating
# Calculate average order value for each restaurant
avg_order_value = df.groupby('restaurant_name')['cost_of_the_order'].mean()

# Calculate average rating for each restaurant
avg_rating = df_rated.groupby('restaurant_name')['rating'].mean()

# Get top 10 restaurants by revenue
top_10_restaurants = revenue_by_restaurant.head(10).index

# Filter data for top 10 restaurants
df_top10 = df[df['restaurant_name'].isin(top_10_restaurants)]

# Create a new DataFrame for plotting
plot_df = pd.DataFrame({
    'Restaurant': top_10_restaurants,
    'Revenue': revenue_by_restaurant.loc[top_10_restaurants],
    'Average Order Value': avg_order_value.loc[top_10_restaurants],
    'Average Rating': avg_rating.loc[top_10_restaurants]
})

# Create 3D scatter plot
fig = px.scatter_3d(plot_df, x='Average Order Value', y='Average Rating', z='Revenue',
                    color='Restaurant', size_max=10, opacity=0.7)

fig.update_layout(title='Company Revenue vs. Average Order Value and Rating (Top 10 Restaurants)',
                  scene=dict(xaxis_title='Average Order Value',
                             yaxis_title='Average Rating',
                             zaxis_title='Revenue'))


This content originally appeared on DEV Community and was authored by ANNA LAPUSHNER


Print Share Comment Cite Upload Translate Updates
APA

ANNA LAPUSHNER | Sciencx (2024-08-13T19:50:02+00:00) kill it with the 3D scatter plot. Retrieved from https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/

MLA
" » kill it with the 3D scatter plot." ANNA LAPUSHNER | Sciencx - Tuesday August 13, 2024, https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/
HARVARD
ANNA LAPUSHNER | Sciencx Tuesday August 13, 2024 » kill it with the 3D scatter plot., viewed ,<https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/>
VANCOUVER
ANNA LAPUSHNER | Sciencx - » kill it with the 3D scatter plot. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/
CHICAGO
" » kill it with the 3D scatter plot." ANNA LAPUSHNER | Sciencx - Accessed . https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/
IEEE
" » kill it with the 3D scatter plot." ANNA LAPUSHNER | Sciencx [Online]. Available: https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/. [Accessed: ]
rf:citation
» kill it with the 3D scatter plot | ANNA LAPUSHNER | Sciencx | https://www.scien.cx/2024/08/13/kill-it-with-the-3d-scatter-plot/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.