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: src/afcharts/cookbook/01-matplotlib-usage.qmd
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -748,6 +748,12 @@ fig
748
748
This line chart uses the afcharts theme. There are pale grey grid lines extending from the y axis, and there is a thicker dark blue line representing the data. A dotted horizontal line has been added at 70 years of age, with an annotation to label it.
749
749
</div>
750
750
751
+
### Saving figures
752
+
753
+
The afcharts style uses a larger base font size (14pt vs Matplotlib's default 10pt) for accessibility. The `figure.figsize` parameter is intentionally not set in the style sheet — the default canvas remains 6.4 × 4.8 inches.
754
+
755
+
By default, `savefig` saves at exactly `figure.figsize`. If you pass `bbox_inches='tight'`, the output is cropped to the bounding box of all content, so dimensions will vary between charts. Avoid this if you need a consistent, fixed output size.
756
+
751
757
### Wrapping text
752
758
753
759
If text is too long, it may be cut off or distort the dimensions of the chart. To avoid this, text can be wrapped to multiple lines using the `textwrap` module. The width argument controls how many characters are allowed on each line before wrapping. See the figure title below for an example.
Copy file name to clipboardExpand all lines: src/afcharts/cookbook/04-colour-palettes.qmd
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ get_af_colours("duo")
24
24
25
25
### Number of colours
26
26
27
-
By default, `get_af_colours()` will return all colours in the given palette. For the categorical palette, the number of colours returned can be set with the `number_of_colours` argument.
27
+
By default, `get_af_colours()` will return all core colours in the given palette with grey as an optional addition. For the categorical and sequential palettes, the number of colours returned can be set with the `number_of_colours` argument.
28
28
29
29
For example, to return four colours from the categorical palette as hex codes:
30
30
```{python}
@@ -40,7 +40,7 @@ For example, to return the sequential colour palette as a list of rgb code tuple
The `sequential` colour palette should be used for data where the order has some meaning, such as age groups.
105
105
106
+
The pale grey colour should be used for cases when, for example, you have no data or have suppressed the value. By default, the sequential palette returned by `get_af_colours()` does not include the pale grey. To include it, set `include_grey=True`.
0 commit comments