plotly/boxed-axis-frame
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| plotly | info, and warning with style = "strict". A rule of the house style |
unsafe, with xpd check --fix --unsafe-fixes |
All versions |
mirror=True repeats the axis line on the far side of the plot, which closes a box around the data and adds ink that shows nothing. Drop mirror, and keep the two axis lines.
fig = px.scatter(df, x="day", y="tip")fig.update_xaxes(showline=True, mirror=True)fig.update_yaxes(showline=True, mirror=True)fig.update_xaxes(showline=True)fig.update_yaxes(showline=True)What the rule reports
Section titled “What the rule reports”The rule reports mirror=True, mirror="all", mirror="ticks" or mirror="allticks" beside showline=True on an x or y axis of a plotly figure, in update_xaxes, update_yaxes, go.layout.XAxis, go.layout.YAxis, and in xaxis=dict(...) or xaxis={...} in update_layout, go.Layout and go.Figure.
How to fix it
Section titled “How to fix it”xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.
The unsafe fix drops mirror, so the box around the plot is open.
The book redraws a chart until it has "only the frame lines remaining as pure non-information"
(page 103), and says that a frame which shows the range of the data "should replace the
non-data-bearing frame" (page 131). mirror=True draws each axis line a second time on the
far side of the plot, which closes a box around the data. The x axis line had one segment with
showline=True alone and two with mirror=True. Under the default template mirror=True
without showline drew no line, so the rule reads the two together.
Questions of the presentation review
Section titled “Questions of the presentation review”The rule reports in code what these questions of the presentation guides (xpd charts, xpd tables, and xpd views) ask of the drawn display.
| Question | Page | Principle | What it asks |
|---|---|---|---|
| data-ink | 96 | Maximize the data-ink ratio | Which ink shows no data? Could the background tint, frame, ticks, debris or uniform notes be erased or moved to the caption without loss, after a revision that compares versions? |
| bar-erase | 129 | Redesign the bar chart | Could the bar chart drop its box, its vertical axis line and its ticks, with white grid lines cut through the bars and a thin baseline? |
Diagnostic message
Section titled “Diagnostic message”mirror=$M repeats the axis line on the far side of the plot, which closes a box around the data. The x axis line went from one segment to two. Tufte counts frame lines as ink that shows no data. Keep showline=True for the two axis lines and drop mirror.See all rules in the plotly pack.