Skip to content
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

Color docs #2030

Merged
merged 3 commits into from
Jan 8, 2020
Merged

Color docs #2030

merged 3 commits into from
Jan 8, 2020

Conversation

nicolaskruchten
Copy link
Contributor

Once this is merged, I'll update #2016 and #2017

```python
import plotly.express as px
df = px.data.tips()
fig = px.scatter(df, x="total_bill", y="tip", color="smoker", title="String 'smoker' values mean categorical colors")
Copy link
Contributor

Choose a reason for hiding this comment

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

break line before title to avoid scrolling

import plotly.express as px
df = px.data.gapminder()
fig = px.line(df, y="lifeExp", x="year", color="continent", line_group="country",
line_shape="spline", render_mode="svg",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the example short by removing this line? Is it a bug that spline gives an error when not using render_mode='svg'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think webgl doesn't support spline, so maybe yes, spline should force svg? maybe too magical... To be honest I just didn't like the look of the figure in webgl :)

fig.show()
```

### Explicity Constructing a Color Sequence
Copy link
Contributor

Choose a reason for hiding this comment

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

Explicitly

- **color scales** represent a mapping between the range 0 to 1 and some color domain within which colors are to be interpolated (unlike [categorical color sequences](/python/categorical-color/) which are never interpolated). Color scale defaults depend on the `layout.colorscales` attributes of the active [template](/python/templates/), and can be explicitly specified using the `color_continuous_scale` argument for many [Plotly Express](/python/plotly-express/) functions or the `colorscale` argument in various `graph_objects` such as `layout.coloraxis` or `marker.colorscale` in `go.Scatter` traces. For example `[(0,"blue"), (1,"red")]` is a simple color scale that interpolated between blue and red via purple, which can also be implicitly represented as `["blue", "red"]` and happens to be one of the [built-in color scales](/python/builtin-colorscales) and therefore referred to as `"bluered"` or `plotly.colors.sequential.Bluered`.
- **color ranges** represent the minimum to maximum range of data to be mapped onto the 0 to 1 input range of the color scale. Color ranges default to the range of the input data and can be explicitly specified using either the `range_color` or `color_continous_midpoint` arguments for many Plotly Express functions, or `cmin`/`cmid`/`cmax` or `zmin`/`zmid`/`zmax` for various `graph_objects` such as `layout.coloraxis.cmin` or `marker.cmin` in `go.Scatter` traces. For example, if a color range of `[100, 200]` is used with the color scale above, then any mark with a color value of 100 or less will be blue, and 200 or more will be red. Marks with values in between will be various shades of purple.
- **color bars** are legend-like visible representations of the color range and color scale with optional tick labels and tick marks. Color bars can be configured with attributes inside `layout.coloraxis.colorbar` or in places like `marker.colorbar` in `go.Scatter` traces.
- **color axes** connect color scales, color ranges and color bars to a trace's data. By default, any colorable attribute in a trace is attached to its own local color axis, but color axes may also be shared across attributes and traces by setting e.g. `marker.coloraxis` in `go.Scatter` traces. Local color axis attributes are configured within traces e.g. `marker.showscale` whereas shared color axis attributes are configured within the Layout e.g. `layout.coloraxis.showscale`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
e.g. marker.coloraxis in go.Scatter or coloraxis in go.Heatmap traces.

```python
import plotly.express as px
df = px.data.tips()
df["size"] = df["size"].astype(str)
Copy link
Contributor

Choose a reason for hiding this comment

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

show how to go back to float as in the categorical page? It's a common pattern to open a csv file with string columns which are in fact numerical values.

@emmanuelle
Copy link
Contributor

This is amazing work, thank you!

  • I left a couple of minor comments, none of them is very important.
  • In the existing colorscale page which you modified, I wonder if it would be possible to intertwine more the px and graph_objects examples. At the moment it's one big block of px and then another block of graph_objects, but the concepts are actually the same so maybe it would make more sense. It can also be done later also.
  • the CI seems to fail because of the order of the files?

@nicolaskruchten
Copy link
Contributor Author

I addressed most comments but left PX/GO separate for now... We can do another pass later I think.

@emmanuelle
Copy link
Contributor

💃 when everything's green!

@nicolaskruchten nicolaskruchten merged commit 277b9c9 into doc-prod Jan 8, 2020
@nicolaskruchten nicolaskruchten deleted the colordocs branch June 19, 2020 16:15
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.

2 participants