Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc524fe9

Browse files
author
“mahdis-z”
committed
cmid&zmid
1 parentfdb1c4c commitc524fe9

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

‎python/colorscales.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension:.md
77
format_name:markdown
88
format_version:'1.1'
9-
jupytext_version:1.1.1
9+
jupytext_version:1.2.1
1010
kernelspec:
1111
display_name:Python 3
1212
language:python
@@ -20,7 +20,7 @@ jupyter:
2020
name:python
2121
nbconvert_exporter:python
2222
pygments_lexer:ipython3
23-
version:3.6.8
23+
version:3.7.3
2424
plotly:
2525
description:How to set colorscales and heatmap colorscales in Python and Plotly.
2626
Divergent, sequential, and qualitative colorscales.
@@ -32,8 +32,8 @@ jupyter:
3232
name:Colorscales
3333
order:22
3434
permalink:python/colorscales/
35-
thumbnail:thumbnail/heatmap_colorscale.jpg
3635
redirect_from:python/logarithmic-color-scale/
36+
thumbnail:thumbnail/heatmap_colorscale.jpg
3737
v4upgrade:true
3838
---
3939

@@ -196,6 +196,41 @@ fig.add_trace(go.Heatmap(
196196
fig.show()
197197
```
198198

199+
###Colorscale Midpoint
200+
The following example uses[cmid](https://plot.ly/python/reference/#scatter-marker-cmid) attribute to set the mid-point of the color domain by scaling[cmin](https://plot.ly/python/reference/#scatter-marker-cmin) and/or[cmax](https://plot.ly/python/reference/#scatter-marker-cmax) to be equidistant to this point. It only has impact when[marker.line.color](https://plot.ly/python/reference/#scattercarpet-marker-line-color) sets to a numerical array, and[marker.line.cauto](https://plot.ly/python/reference/#scattercarpet-marker-line-cauto) is`True`. The heatmap chart uses[zmid](https://plot.ly/python/reference/#heatmap-zmid) attribute to set the mid-point of the color domain by scaling[zmin](https://plot.ly/python/reference/#heatmap-zmin) and/or[zmax](https://plot.ly/python/reference/#heatmap-zmax) to be equidistant to this point.
201+
202+
```python
203+
import plotly.graph_objectsas go
204+
205+
fig= go.Figure()
206+
207+
fig.add_trace(go.Scatter(
208+
y=[1,2,0,1],
209+
mode="markers",
210+
marker={
211+
"size":25,
212+
"color": [1,4,8],
213+
"cmid":0,
214+
"colorbar": {
215+
"len":0.5,
216+
"y":1,
217+
"yanchor":"top",
218+
"title": {"text":"cmid=0","side":"right"}
219+
}}))
220+
221+
fig.add_trace(go.Heatmap(
222+
z=[[1,5,3,2], [5,3,7,9], [3,2,6,4]],
223+
zmid=10,
224+
colorbar={
225+
"len":0.5,
226+
"y":0.5,
227+
"yanchor":"top",
228+
"title": {"text":"zmid=10","side":"right"}
229+
}))
230+
231+
fig.show()
232+
```
233+
199234
###Custom Contour Plot Colorscale
200235

201236
```python
@@ -271,7 +306,7 @@ fig = go.Figure(go.Heatmap(
271306
[1.,'rgb(0, 0, 0)'],#100000
272307

273308
],
274-
colorbar=dict(
309+
colorbar=dict(
275310
tick0=0,
276311
tickmode='array',
277312
tickvals= [0,1000,10000,100000]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp