How to make 3D subplots using plotly?

How to make 3D subplots using plotly?

How to make 3D subplots using plotly?

This recipe helps you make 3D subplots using plotly


Recipe Objective

Make 3D subplots using plotly

Plotly gives a function through which we can make subplots. Lets understand this practically.

Step 1 - Import libraries

import plotly.graph_objects as go from plotly.subplots import make_subplots import numpy as np

Step 2 - Initialize subplots

fig = make_subplots( rows=2, cols=2, specs=[[{'type': 'surface'}, {'type': 'surface'}], [{'type': 'surface'}, {'type': 'surface'}]])

Here we are initializing figure with 4 3D subplots

Step 3 - Generate the Data

Data_x = np.linspace(-5, 80, 10) Data_y = np.linspace(-5, 60, 10) xGrid, yGrid = np.meshgrid(Data_y, Data_x) Data_z = xGrid ** 3 + yGrid ** 3

Step 4 - Plot graph

fig.add_trace( go.Surface(x=Data_x, y=Data_y, z=Data_z, colorscale='Viridis', showscale=False), row=1, col=1) fig.add_trace( go.Surface(x=Data_x, y=Data_y, z=Data_z, colorscale='RdBu', showscale=False), row=1, col=2) fig.add_trace( go.Surface(x=Data_x, y=Data_y, z=Data_z, colorscale='YlOrRd', showscale=False), row=2, col=1) fig.add_trace( go.Surface(x=Data_x, y=Data_y, z=Data_z, colorscale='YlGnBu', showscale=False), row=2, col=2) fig.update_layout( title_text='Differnt 3D subplots with different color scale', height=900, width=900 )

Here we are adding surfaces to the subplots and then plotting them

Relevant Projects

Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.