Skip to content

add macros that turn unit from cm/mm/in to px#5066

Closed
kaikuhn wants to merge 1 commit intoJuliaPlots:v2from
kaikuhn:v2
Closed

add macros that turn unit from cm/mm/in to px#5066
kaikuhn wants to merge 1 commit intoJuliaPlots:v2from
kaikuhn:v2

Conversation

@kaikuhn
Copy link

@kaikuhn kaikuhn commented Mar 26, 2025

Description

It can be useful to be able to define the size of plots in other units.
Therefor these macros convert the tuple of size in px before the size tuple is evaluated by the function.

Attribution

Things to consider

It shouldn't affect anything since the macros are executed before the tuple is transferred to the plot function.

  • Does it work on log scales?
  • Does it work in layouts?
  • Does it work in recipes?
  • Does it work with multiple series in one call?
  • PR includes or updates tests?
  • PR includes or updates documentation?

Considerations

I have seen that other values like left_margin are implemented by the Measure package.
To apply this method to the plot size the changes would have more impact, because the pixels unit needs to be recalculated for the selected DPI value after receipt.

Syntax correction

fixing unknown variable ..Commons

macro syntax

correct unit calculation

final changes

Readd inch2px
@BeastyBlacksmith
Copy link
Member

Why do these need to be macros and what benefit do they have over the converter functions we already have further down in the code?

@kaikuhn
Copy link
Author

kaikuhn commented Apr 22, 2025

Why do these need to be macros and what benefit do they have over the converter functions we already have further down in the code?

Hello BeastyBlacksmith,

Thank you for your message.
It needn't to be macros. It was just a suggestion for an easy way of setting the figure size without changing anything else in the code.
As I mentioned it would be nice to have a similar syntax for setting absolute length as it is handled for e.g left_margin using the Measure package (It is the same syntax it is in pyplot).
Is there anything planned in this direction?

To the functions you mentioned below the code:
As I had seen they haven't been exported yet and are only for single values - not tuples.
(Of cause you can call the function for every value separately, but my feeling was it would be more convenient to either extend the functionality of that function to take tuples, or define something new)

@kaikuhn kaikuhn closed this by deleting the head repository Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants