plotters-rs / plotters

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely πŸ¦€ πŸ“ˆπŸš€
https://plotters-rs.github.io/home/
MIT License
3.79k stars 273 forks source link

[Feature Request] Arbitrary angle for text rotation #231

Open ecclarke42 opened 3 years ago

ecclarke42 commented 3 years ago

What is the feature ?

It would be nice to be able to rotate text to some arbitrary angle (besides just 0/90/180/270 degrees)

(Optional) Why this feature is useful and how people would use the feature ?

I'm using plotters to generate some bar charts, but when the number of bars/labels gets relatively large (or the labels are long), it can be impossible to keep the labels a readable size without overlapping.

Coming from a limited plotly background, it would be nice to be able to replicate what they do with their bar charts when there are a lot of labels (albeit a bit more manually) by slanting them. For example, these screenshots from their bar chart page (same chart, just zoomed in to show fewer bars): image image

(Optional) Additional Information

Without knowing too much about the details of plotters-backend, I'd image that just adding a RotateAngle(u32) (or some float?) variant to the FontTransform enum and adding something like

FontTransform::RotateAngle(angle) => (x * angle.cos(), y * angle.sin()),

to the transform method. I'll do exactly that in a PR and try to run the current plotters tests

Pierstoval commented 4 months ago

I see that this feature was somehow merged at one point, then reversed.

Is there anyone working on it right know? I'm okay with funding the work if necessary πŸ˜‰