Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c34711e

Browse files
docs for time-format
1 parent cf1ab44 commit c34711e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

doc/python/hover-text-and-formatting.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jupyter:
3434

3535
### Hover Labels
3636

37-
One of the most deceptively-power features of interactive visualization using Plotly is the ability for the user to reveal more information about a data point by moving their mouse cursor over the point and having a hover label appear.
37+
One of the most deceptively-power features of interactive visualization using Plotly is the ability for the user to reveal more information about a data point by moving their mouse cursor over the point and having a hover label appear.
3838

3939
There are three hover modes available in Plotly. The default setting is `layout.hovermode='closest'`, wherein a single hover label appears for the point directly underneath the cursor.
4040

@@ -51,7 +51,7 @@ fig.update_traces(mode="markers+lines")
5151
fig.show()
5252
```
5353

54-
#### Hovermode `x` or `y`
54+
#### Hovermode `x` or `y`
5555

5656
If `layout.hovermode='x'` (or `'y'`), a single hover label appears per trace, for points at the same `x` (or `y`) value as the cursor. If multiple points in a given trace exist at the same coordinate, only one will get a hover label. In the line plot below we have forced markers to appear, to make it clearer what can be hovered over, and we have disabled the built-in Plotly Express `hovertemplate` by setting it to `None`, resulting in a more compact hover label per point:
5757

@@ -112,8 +112,8 @@ fig.update_traces(mode="markers+lines")
112112

113113
fig.update_layout(
114114
hoverlabel=dict(
115-
bgcolor="white",
116-
font_size=16,
115+
bgcolor="white",
116+
font_size=16,
117117
font_family="Rockwell"
118118
)
119119
)
@@ -143,7 +143,7 @@ fig.show()
143143
`hover_data` can also be a dictionary. Its keys are existing columns of the `dataframe` argument, or new labels. For an existing column, the values can be
144144
* `False` to remove the column from the hover data (for example, if one wishes to remove the column of the `x` argument)
145145
* `True` to add a different column, with default formatting
146-
* a formatting string starting with `:` for numbers [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `|` for dates in [d3-time-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format), for example `:.3f`, `|%a`.
146+
* a formatting string starting with `:` for numbers [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `|` for dates in [d3-time-format's syntax](https://github.com/d3/d3-time-format), for example `:.3f`, `|%a`.
147147

148148
It is also possible to pass new data as values of the `hover_data` dict, either as list-like data, or inside a tuple, which first element is one of the possible values described above for existing columns, and the second element correspond to the list-like data, for example `(True, [1, 2, 3])` or `(':.1f', [1.54, 2.345])`.
149149

@@ -170,7 +170,7 @@ fig.show()
170170
### Customizing hover text with a hovertemplate
171171

172172
To customize the tooltip on your graph you can use the [hovertemplate](https://plotly.com/python/reference/pie/#pie-hovertemplate) attribute of `graph_objects` tracces, which is a template string used for rendering the information that appear on hoverbox.
173-
This template string can include `variables` in %{variable} format, `numbers` in [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `date` in [d3-time-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format). In the example below, the empty `<extra></extra>` tag removes the part of the hover where the trace name is usually displayed in a contrasting color. The `<extra>` tag can be used to display other parts of the hovertemplate, it is not reserved for the trace name.
173+
This template string can include `variables` in %{variable} format, `numbers` in [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format), and `date` in [d3-time-format's syntax](https://github.com/d3/d3-time-format). In the example below, the empty `<extra></extra>` tag removes the part of the hover where the trace name is usually displayed in a contrasting color. The `<extra>` tag can be used to display other parts of the hovertemplate, it is not reserved for the trace name.
174174

175175
Note that a hovertemplate customizes the tooltip text, while a [texttemplate](https://plotly.com/python/reference/pie/#pie-texttemplate) customizes the text that appears on your chart. <br>
176176

@@ -228,7 +228,7 @@ df_2007 = px.data.gapminder().query("year==2007")
228228
fig = px.scatter(df_2007, x="gdpPercap", y="lifeExp", log_x=True, color='continent'
229229
)
230230
print("plotly express hovertemplate:", fig.data[0].hovertemplate)
231-
fig.update_traces(hovertemplate='GDP: %{x} <br>Life Expectancy: %{y}') #
231+
fig.update_traces(hovertemplate='GDP: %{x} <br>Life Expectancy: %{y}') #
232232
fig.update_traces(hovertemplate=None, selector={'name':'Europe'}) # revert to default hover
233233
print("user_defined hovertemplate:", fig.data[0].hovertemplate)
234234
fig.show()
@@ -404,4 +404,4 @@ fig.show()
404404

405405
#### Reference
406406

407-
See https://plotly.com/python/reference/ for more information and chart attribute options!
407+
See https://plotly.com/python/reference/ for more information and chart attribute options!

doc/python/text-and-annotations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ fig.show()
537537
### Customize Displayed Text with a Text Template
538538

539539
To show an arbitrary text in your chart you can use [texttemplate](https://plotly.com/python/reference/pie/#pie-texttemplate), which is a template string used for rendering the information, and will override [textinfo](https://plotly.com/python/reference/treemap/#treemap-textinfo).
540-
This template string can include `variables` in %{variable} format, `numbers` in [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `date` in [d3-time-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format).
540+
This template string can include `variables` in %{variable} format, `numbers` in [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `date` in [d3-time-format's syntax](https://github.com/d3/d3-time-format).
541541
`texttemplate` customizes the text that appears on your plot vs. [hovertemplate](https://plotly.com/python/reference/pie/#pie-hovertemplate) that customizes the tooltip text.
542542

543543
```python
@@ -606,4 +606,4 @@ fig.show()
606606

607607
#### Reference
608608

609-
See https://plotly.com/python/reference/layout/annotations/ for more information and chart attribute options!
609+
See https://plotly.com/python/reference/layout/annotations/ for more information and chart attribute options!

doc/python/tick-formatting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@ fig.show()
194194
```
195195

196196
#### Reference
197-
See https://plotly.com/python/reference/layout/xaxis/ for more information and chart attribute options!
197+
See https://plotly.com/python/reference/layout/xaxis/ for more information and chart attribute options!

0 commit comments

Comments
 (0)