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
I want to add an image to the background of the plot. I saw the example but it doesn't work.
I have these dependencies :
[dependencies]
image = "0.25.8"
plotters = { version = "0.3.7", features = ["image", "bitmap_backend"] }
And the error occurs at this line :
let elem: BitMapElement<_> = ((0.05, 0.95), image).into();
error[E0277]: the trait bound `plotters::element::BitMapElement<'_, _>: From<(({float}, {float}), DynamicImage)>` is not satisfied
--> src\main.rs:35:56
|
35 | let elem: BitMapElement<_> = ((0.05, 0.95), image).into();
| ^^^^ the trait `From<(({float}, {float}), DynamicImage)>` is not implemented for `plotters::element::BitMapElement<'_, _>`
|
= help: the following other types implement trait `From<T>`:
plotters::element::BitMapElement<'_, Coord, BGRXPixel>
plotters::element::BitMapElement<'_, Coord>
= note: required for `(({float}, {float}), DynamicImage)` to implement `Into<plotters::element::BitMapElement<'_, _>>`
@chimivari
I encountered the same issue.
I can't see your Cargo.lock file, so I can't be certain, but I suspect the cause is that plotters depends on an older version of the image crate (0.24.x), while your program depends on the latest version (0.25.x), and their APIs differ.
Checking the image crate's version by running cargo tree should clarify the exact situation. If the situation is as described above, temporarily downgrading the image crate version your program depends on to 0.24 should work as a workaround.
Activity
noritada commentedon Nov 26, 2025
@chimivari
I encountered the same issue.
I can't see your Cargo.lock file, so I can't be certain, but I suspect the cause is that plotters depends on an older version of the image crate (0.24.x), while your program depends on the latest version (0.25.x), and their APIs differ.
Checking the image crate's version by running
cargo treeshould clarify the exact situation. If the situation is as described above, temporarily downgrading the image crate version your program depends on to 0.24 should work as a workaround.