Customizing caps in volume plot
In plotly, for more clear visualization of the internal surface, it is possible that the cap can be removed. Caps are visible by default.
Example 1:
Python3
import plotly.graph_objects as go import plotly.express as px import numpy as np df = px.data.tips() x1 = np.linspace( - 4 , 4 , 9 ) y1 = np.linspace( - 5 , 5 , 11 ) z1 = np.linspace( - 5 , 5 , 11 ) X, Y, Z = np.meshgrid(x1, y1, z1) values = (np.sin(X * * 2 + Y * * 2 )) / (X * * 2 + Y * * 2 ) fig = go.Figure(data = go.Volume( x = X.flatten(), y = Y.flatten(), z = Z.flatten(), value = values.flatten(), opacity = 0.1 , caps = dict (x_show = False , y_show = False , z_show = True ), )) fig.show() |
Output:
Example 2:
Python3
import plotly.graph_objects as go import plotly.express as px import numpy as np df = px.data.tips() x1 = np.linspace( - 4 , 4 , 9 ) y1 = np.linspace( - 5 , 5 , 11 ) z1 = np.linspace( - 5 , 5 , 11 ) X, Y, Z = np.meshgrid(x1, y1, z1) values = (np.sin(X * * 2 + Y * * 2 )) / (X * * 2 + Y * * 2 ) fig = go.Figure(data = go.Volume( x = X.flatten(), y = Y.flatten(), z = Z.flatten(), value = values.flatten(), opacity = 0.1 , caps = dict (x_show = False , y_show = True , z_show = False ), )) fig.show() |
Output:
3D Volume Plots using Plotly in Python
Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization library.
Contact Us