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/axes.md
+32-1
Original file line number
Diff line number
Diff line change
@@ -622,6 +622,37 @@ fig.update_layout(
622
622
fig.show()
623
623
```
624
624
625
+
### Fixed Ratio Axes with Compressed domain
626
+
627
+
If an axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), `constrain` determines how that happens: by increasing the "range" (default), or by decreasing the "domain".
628
+
629
+
```python
630
+
import plotly.graph_objects as go
631
+
632
+
fig = go.Figure()
633
+
634
+
fig.add_trace(go.Scatter(
635
+
x= [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
636
+
y= [0,0,1,1,3,3,2,2,3,3,1,1,0,0]
637
+
))
638
+
639
+
fig.update_layout(
640
+
width=800,
641
+
height=500,
642
+
title="fixed-ratio axes with compressed axes",
643
+
xaxis=dict(
644
+
range=[-1,4], # sets the range of xaxis
645
+
constrain="domain", # meanwhile compresses the xaxis by decreasing its "domain"
646
+
),
647
+
yaxis=dict(
648
+
scaleanchor="x",
649
+
scaleratio=1,
650
+
),
651
+
)
652
+
653
+
fig.show()
654
+
```
655
+
625
656
#### Reversed Axes
626
657
627
658
You can tell plotly's automatic axis range calculation logic to reverse the direction of an axis by setting the `autorange` axis property to `"reversed"`.
@@ -682,7 +713,7 @@ fig.show()
682
713
683
714
The axis auto-range calculation logic can be configured using the `rangemode` axis parameter.
684
715
685
-
If `rangemode` is `"normal"` (the default), the range is computed based on the min and max values of the input data. If `"tozero"`, the the range will always include zero. If `"nonnegative"`, the range will not extend below zero, regardless of the input data.
716
+
If `rangemode` is `"normal"` (the default), the range is computed based on the min and max values of the input data. If `"tozero"`, the range will always include zero. If `"nonnegative"`, the range will not extend below zero, regardless of the input data.
686
717
687
718
Here is an example of configuring a faceted scatter plot created using Plotly Express to always include zero for both the x and y axes.
Copy file name to clipboardExpand all lines: doc/python/builtin-colorscales.md
+27-14
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ jupyter:
5
5
text_representation:
6
6
extension: .md
7
7
format_name: markdown
8
-
format_version: '1.2'
8
+
format_version: "1.2"
9
9
jupytext_version: 1.3.1
10
10
kernelspec:
11
11
display_name: Python 3
@@ -22,34 +22,39 @@ jupyter:
22
22
pygments_lexer: ipython3
23
23
version: 3.6.8
24
24
plotly:
25
-
description: A reference for the built-in named continuous (sequential, diverging
26
-
and cylclical) colorscales in Plotly.
25
+
description:
26
+
A reference for the built-in named continuous (sequential, diverging
27
+
and cylclical) color scales in Plotly.
27
28
display_as: file_settings
28
29
has_thumbnail: true
29
30
ipynb: ~notebook_demo/187
30
31
language: python
31
32
layout: base
32
-
name: Built-in Continuous Colorscales
33
+
name: Built-in Continuous Color Scales
33
34
order: 27
34
35
permalink: python/builtin-colorscales/
35
36
thumbnail: thumbnail/heatmap_colorscale.jpg
36
37
v4upgrade: true
37
38
---
38
39
39
-
### Using Built-In Colorscales
40
+
### Using Built-In Continuous Color Scales
40
41
41
42
Many Plotly Express functions accept a `color_continuous_scale` argument and many trace
42
43
types have a `colorscale` attribute in their schema. Plotly comes with a large number of
43
-
built-in continuous colorscales, which can be referred to in Python code when setting the above arguments,
44
+
built-in continuous color scales, which can be referred to in Python code when setting the above arguments,
44
45
either by name in a case-insensitive string e.g. `px.scatter(continuous_color_scale="Viridis"`) or by reference e.g.
45
46
`go.Scatter(marker_colorscale=plotly.colors.sequential.Viridis)`. They can also be reversed by adding `_r` at the end
46
47
e.g. `"Viridis_r"` or `plotly.colors.sequential.Viridis_r`.
47
48
48
49
The `plotly.colours` module is also available under `plotly.express.colors` so you can refer to it as `px.colors`.
49
50
50
-
When using continuous colorscales, you will often want to [configure various aspects of its range and colorbar](/python/colorscales/).
51
+
When using continuous color scales, you will often want to [configure various aspects of its range and colorbar](/python/colorscales/).
51
52
52
-
### Named Built-In Colorscales
53
+
### Discrete Color Sequences
54
+
55
+
Plotly also comes with some built-in [discrete color sequences](/python/discrete-color/) which are _not intended_ to be used with the `color_continuous_scale` argument as they are not designed for interpolation to occur between adjacent colors.
56
+
57
+
### Named Built-In Continuous Color Scales
53
58
54
59
You can use any of the following names as string values to set `continuous_color_scale` or `colorscale` arguments.
55
60
These strings are case-insensitive and you can append `_r` to them to reverse the order of the scale.
print("\n".join(wrap("".join('{:<12}'.format(c) for c in named_colorscales), 96)))
63
68
```
64
69
65
-
### Built-In Sequential Colorscales
70
+
Built-in color scales are stored as lists of CSS colors:
71
+
72
+
```python
73
+
import plotly.express as px
74
+
75
+
print(px.colors.sequential.Plasma)
76
+
```
77
+
78
+
### Built-In Sequential Color scales
66
79
67
80
A collection of predefined sequential colorscales is provided in the `plotly.colors.sequential` module. Sequential color scales are appropriate for most continuous data, but in some cases it can be helpful to use a diverging or cyclical color scale (see below).
68
81
@@ -78,12 +91,12 @@ fig.show()
78
91
Note: `RdBu` was included in this module by mistake, even though it is a diverging color scale.
79
92
It is intentionally left in for backwards-compatibility reasons.
80
93
81
-
### Built-In Diverging Colorscales
94
+
### Built-In Diverging Color scales
82
95
83
-
A collection of predefined diverging colorscales is provided in the `plotly.colors.diverging` module.
96
+
A collection of predefined diverging color scales is provided in the `plotly.colors.diverging` module.
84
97
Diverging color scales are appropriate for continuous data that has a natural midpoint
85
98
other otherwise informative special value, such as 0 altitude, or the boiling point
86
-
of a liquid. These scales are intended to be used when [explicitly setting the midpoint of the scale](/python/colorscales/#setting-the-midpoint-of-a-diverging-colorscale).
99
+
of a liquid. These scales are intended to be used when [explicitly setting the midpoint of the scale](/python/colorscales/#setting-the-midpoint-of-a-color-range-for-a-diverging-color-scale).
87
100
88
101
Here are all the built-in scales in the `plotly.colors.diverging` module:
0 commit comments