cpmech / plotpy

Rust plotting library using Python (Matplotlib)
MIT License
65 stars 6 forks source link

If use the default matplotlib on Rocky (<3.5.0), below fix should be added #70

Closed supernova4869 closed 1 week ago

supernova4869 commented 2 weeks ago

in file plot.rs:

    /// Sets the ticks and labels along x
    pub fn set_ticks_x_labels<'a, S, T, U>(&mut self, ticks: &'a T, labels: &[S]) -> &mut Self
    where
        S: std::fmt::Display,
        T: AsVector<'a, U>,
        U: 'a + std::fmt::Display,
    {
        assert_eq!(ticks.vec_size(), labels.len());
        vector_to_array(&mut self.buffer, "tx", ticks);
        vector_to_strings(&mut self.buffer, "lx", labels);
---> Line 713        write!(&mut self.buffer, "plt.gca().set_xticks(tx)\nplt.gca().set_xticklabels(lx)\n").unwrap();
        self
    }

    /// Sets the ticks and labels along y
    pub fn set_ticks_y_labels<'a, S, T, U>(&mut self, ticks: &'a T, labels: &[S]) -> &mut Self
    where
        S: std::fmt::Display,
        T: AsVector<'a, U>,
        U: 'a + std::fmt::Display,
    {
        assert_eq!(ticks.vec_size(), labels.len());
        vector_to_array(&mut self.buffer, "ty", ticks);
        vector_to_strings(&mut self.buffer, "ly", labels);
---> Line 727        write!(&mut self.buffer, "plt.gca().set_yticks(ty)\nplt.gca().set_yticklabels(ly)\n").unwrap();
        self
    }

Thus it could avoid the label error with old version matplotlib.

cpmech commented 1 week ago

Hi, thanks for the suggestion! This is now implemented in version 1.7.1