Skip to content

Commit fb22ee9

Browse files
committed
Improve the documentation
1 parent 242e508 commit fb22ee9

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/figure.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ impl Figure {
4343
/// Return a new `Figure`.
4444
///
4545
/// ⚠ The figures created with this function will not be displayed
46-
/// with [`crate::show`]. They can be [saved][Figure::save] to files.
46+
/// with [`show`][crate::pyplot::show]. They can be
47+
/// [saved][Figure::save] to files.
4748
pub fn new() -> Result<Figure, Error> {
4849
Python::attach(|py| {
4950
let fig = Self::cls(py).call0()
@@ -98,7 +99,7 @@ impl Figure {
9899
/// ⚠ [This does not manage an GUI event loop][GUI]. Consequently,
99100
/// the figure may only be shown briefly or not shown at all if
100101
/// you or your environment are not managing an event loop. Use
101-
/// [`crate::show()`] for that.
102+
/// [`show()`][crate::pyplot::show] for that.
102103
///
103104
/// [GUI]: https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.show
104105
pub fn show(self) -> Result<(), Error> {

src/lib.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,13 @@ impl From<&ImportError> for Error {
103103
}
104104
}
105105

106-
/// A dict-like key-value store for config parameters, including
107-
/// validation.
108-
///
109-
/// Validating functions are defined and associated with rc parameters
110-
/// in [`rcsetup`].
106+
/// A dict-like key-value store for config parameters.
111107
#[derive(Debug)]
112108
pub struct RcParams {
113109
rc: Py<PyDict>,
114110
}
115111

112+
/// Rust types that may be used as [`RcParams`] values.
116113
pub trait RcParamsValue {
117114
fn into_py<'py>(&self, py: Python<'py>) -> impl IntoPyObject<'py>;
118115
}
@@ -146,6 +143,12 @@ impl RcParams {
146143
})
147144
}
148145

146+
/// Set the [RcParam][] `key` to `value`.
147+
///
148+
/// Note that an improper value may only raise an error later such
149+
/// as when [`pyplot::figure`] is called.
150+
///
151+
/// [RcParam]: https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.RcParams
149152
pub fn set<'py>(&self, key: &str, value: impl RcParamsValue) -> Result<(), Error> {
150153
Python::attach(|py| -> Result<_, Error> {
151154
self.rc.bind(py).set_item(key, value.into_py(py))
@@ -167,6 +170,10 @@ impl RcParams {
167170
}
168171
}
169172

173+
/// Return an instance of [`RcParams`] for handling default Matplotlib
174+
/// values.
175+
///
176+
/// Setting values must be done before the figure is created.
170177
pub fn rc_params() -> &'static RcParams {
171178
static RCPARAMS: PyOnceLock<RcParams> = PyOnceLock::new();
172179
Python::attach(|py| {

0 commit comments

Comments
 (0)