You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/3d-surface-plots.md
+24-7Lines changed: 24 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ jupyter:
30
30
order: 3
31
31
page_type: example_index
32
32
permalink: python/3d-surface-plots/
33
+
redirect_from: python/3d-surface-coloring/
33
34
thumbnail: thumbnail/3d-surface.jpg
34
35
---
35
36
@@ -54,7 +55,7 @@ fig.show()
54
55
55
56
### Passing x and y data to 3D Surface Plot
56
57
57
-
If you do not specify `x` and `y` coordinates, integer indices are used for the `x` and `y` axis. You can also pass `x` and `y` values to `go.Surface`.
58
+
If you do not specify `x` and `y` coordinates, integer indices are used for the `x` and `y` axis. You can also pass `x` and `y` values to `go.Surface`.
58
59
59
60
```python
60
61
import plotly.graph_objects as go
@@ -98,7 +99,7 @@ fig.update_layout(title='Mt Bruno Elevation', autosize=False,
98
99
fig.show()
99
100
```
100
101
#### Configure Surface Contour Levels
101
-
This example shows how to slice the surface graph on the desired position for each of x, y and z axis. [contours.x.start](https://plotly.com/python/reference/#surface-contours-x-start) sets the starting contour level value, `end` sets the end of it, and `size` sets the step between each contour level.
102
+
This example shows how to slice the surface graph on the desired position for each of x, y and z axis. [contours.x.start](https://plotly.com/python/reference/#surface-contours-x-start) sets the starting contour level value, `end` sets the end of it, and `size` sets the step between each contour level.
102
103
103
104
```python
104
105
import plotly.graph_objects as go
@@ -165,18 +166,34 @@ fig.show()
165
166
166
167
### Setting the Surface Color
167
168
168
-
You can use the `surfacecolor` attribute to define the color of the surface of your figure. In this example, the surface color is drawn relation to the x-axis data.
169
+
You can use the `surfacecolor` attribute to define the color of the surface of your figure. In this example, the surface color represents the distance from the origin, rather than the default, which is the `z` value.
Copy file name to clipboardExpand all lines: doc/python/sliders.md
+3-50Lines changed: 3 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ jupyter:
34
34
---
35
35
36
36
### Simple Slider Control
37
-
Sliders can be used in Plotly to change the data displayed or style of a plot.
37
+
Sliders can be used in Plotly to change the data displayed or style of a plot.
38
38
39
39
```python
40
40
import plotly.graph_objects as go
@@ -83,61 +83,14 @@ fig.show()
83
83
84
84
#### Methods
85
85
The method determines which [plotly.js function](https://plot.ly/javascript/plotlyjs-function-reference/) will be used to update the chart. Plotly can use several [updatemenu](https://plot.ly/python/reference/#layout-updatemenus-items-updatemenu-buttons-items-button-method) methods to add the slider:
86
+
-`"update"`: modify **data and layout** attributes (as above)
86
87
-`"restyle"`: modify **data** attributes
87
88
-`"relayout"`: modify **layout** attributes
88
-
-`"update"`: modify **data and layout** attributes
89
89
-`"animate"`: start or pause an animation
90
90
91
-
### Update Slider
92
-
```python
93
-
import plotly.graph_objects as go
94
-
import numpy as np
95
-
96
-
# Create figure
97
-
fig = go.Figure()
98
-
99
-
# Add traces, one for each slider step
100
-
for step in np.arange(0, 5, 0.1):
101
-
fig.add_trace(
102
-
go.Scatter(
103
-
visible=False,
104
-
line=dict(color="#00CED1", width=6),
105
-
name="𝜈 = "+str(step),
106
-
x=np.arange(0, 10, 0.01),
107
-
y=np.sin(step * np.arange(0, 10, 0.01))))
108
-
109
-
# Make 10th trace visible
110
-
fig.data[10].visible =True
111
-
112
-
# Create and add slider
113
-
steps = []
114
-
for i inrange(len(fig.data)):
115
-
step =dict(
116
-
method="update",
117
-
args=[{"visible":[False] *len(fig.data)}, # update for traces
118
-
{"title":str(i)} # update for layout
119
-
],
120
-
)
121
-
step["args"][0]["visible"][i] =True# Toggle i'th trace to "visible"
122
-
steps.append(step)
123
-
124
-
sliders = [dict(
125
-
active=10,
126
-
currentvalue={"prefix": "Frequency: "},
127
-
pad={"t": 50},
128
-
steps=steps
129
-
)]
130
-
131
-
fig.update_layout(
132
-
sliders=sliders
133
-
)
134
-
135
-
fig.show()
136
-
```
137
-
138
91
139
92
### Sliders in Plotly Express
140
-
Plotly Express provide sliders, but with implicit animation. The animation can be ommited by removing `updatemenus` in the `layout`:
93
+
Plotly Express provide sliders, but with implicit animation using the `"animate"` method described above. The animation play button can be ommited by removing `updatemenus` in the `layout`:
0 commit comments