Skip to content

cmid&zmid #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 14, 2019
Merged

cmid&zmid #179

merged 6 commits into from
Nov 14, 2019

Conversation

Mahdis-z
Copy link
Contributor

@Mahdis-z Mahdis-z commented Nov 7, 2019

Doc upgrade checklist:

  • random seed is set if using random data
  • file has been moved from unconverted/x/y.md to x/y.md
  • old boilerplate at top and bottom of file has been removed
  • Every example is independently runnable and is optimized for short line count
  • no more plot() or iplot()
  • graph_objs has been renamed to graph_objects
  • fig = <something> call is high up in each example
  • minimal creation of intermediate trace objects
  • liberal use of add_trace and update_layout
  • fig.show() at the end of each example
  • px example at the top if appropriate
  • minimize usage of hex codes for colors in favour of those in https://github.com/plotly/plotly.py-docs/issues/14

z=[[1, 5, 3, 2], [5, 3, 7, 9], [3, 2, 6, 4]],
zmid=10,
colorbar={
"len": 0.5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you could use here a colormap for which the midpoint is white, like 'RdBu', so that the midpoint is more visible.

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

### Colorscale Midpoint
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's marker.color and not marker.line.color?

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

### Colorscale Midpoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the midpoint of a diverging colorscale

fig = go.Figure()

fig.add_trace(go.Scatter(
y=[1, 2, 0, 1],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data should range from, say -5 to +15

"title": {"text": "cmid=0", "side": "right"}
}}))

fig.add_trace(go.Heatmap(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just use 1 trace here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make a separate plot for the heatmap and say "heatmap uses zmid to do the same thing"

"size": 25,
"color": [1,4,8],
"cmid": 0,
"colorbar": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove the colorbar settings

@emmanuelle
Copy link
Contributor

@Mahdis-z I resolved the conflict, please pull from the remote branch first before pushing new commits

@Mahdis-z
Copy link
Contributor Author

@Mahdis-z I resolved the conflict, please pull from the remote branch first before pushing new commits

Awesome, will do

@emmanuelle emmanuelle self-assigned this Nov 13, 2019
fig.add_trace(go.Scatter(
y=list(range(-5,15)),
mode="markers",
marker={"size": 25, "color": list(range(-10,10)), "cmid": 0}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use here asymmetric values to show the effect of cmid (here zero is already the middle of the range). For example

marker={"size": 25, "color": list(range(-3,10)), "cmid": 0}

```python
import plotly.graph_objects as go

a = list(range(-15,5))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start at -10 here to have an asymmetric range

@emmanuelle
Copy link
Contributor

Thanks, 💃 !

@Mahdis-z Mahdis-z merged commit fe5e886 into master Nov 14, 2019
@Mahdis-z Mahdis-z deleted the cmid_zmid_py_ branch November 14, 2019 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants