Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow picts to be used as legend entries in plots #64

Merged
merged 5 commits into from
Aug 15, 2020

Conversation

alex-hhh
Copy link
Sponsor Collaborator

@alex-hhh alex-hhh commented Aug 10, 2020

Updated 2D and 3D plot renderers to accept a pict or a string as the label used in the plot legend:

pr58-2d

The original request was to allow LaTeX notation for the labels, this changeset will enable doing that (and more) by installing the additional latex-pict package and using the pictures produced by that package as labels.

When updated the code which draws the legend, several considerations were made:

  • the get-text-extent method of plot-device% accepts a pict as an argument and will return the picture dimensions in that case. The method was not renamed, however.

  • the font used for text legend entries determines the inset (inside border) of the legend, gap between entries and length of the "sample" line. This was essentially unchanged behavior and using the pict dimensions for this purpose results in bad looking legends, where the inset is too small, the sample line too long and gap too big.

Also updated some of the examples in the documentation to replace x^2 with x², to illustrate that Unicode can be used for the string labels.

Limitations

This pull request does not support picts for titles and axis labels, given that the pull request is big enough already, this will be done separately.

See also

@alex-hhh alex-hhh changed the title Allow pict's to be used as legend entries in plots Allow picts to be used as legend entries in plots Aug 10, 2020
Updated 2D and 3D plot renderers to accept a picture (from the pict library)
or a string as the label used in the plot legend.

The original request was to allow LaTeX notation for the labels, this
changeset will enable doing that (and more) by installing the additional
`latex-pict` package and using the pictures produced by that package as
labels.

When updated the code which draws the legend, several considerations were
made:

* the `get-text-extent` method of `plot-device%` accepts a pict as an argument
  and will return the picture dimensions in that case.  The method was not
  renamed, however.

* the font used for text legend entries determines the inset (inside border)
  of the legend, gap between entries and length of the "sample" line.  This
  was essentially unchanged behavior and using the pict dimensions for this
  purpose results in bad looking legends, where the inset is too small, the
  sample line too long and gap too big.

Also updated some of the examples in the documentation to replace x^2 with x²,
to illustrate that Unicode can be used for the string labels.

See also

* racket#58
* racket/racket#3321
@alex-hhh alex-hhh merged commit 0dbfad4 into racket:master Aug 15, 2020
@alex-hhh alex-hhh deleted the ah/pict-labels branch August 15, 2020 01:35
alex-hhh added a commit to alex-hhh/plot that referenced this pull request Aug 21, 2020
Updated the 2D and 3D plot procedures to accept a picture (from the pict
library) or a string as the label for the `#:title` and`#:{x,y,z}-label``
keywords, as well as the corresponing parameters, `plot-title` and
`plot-{x,y,z}-label`.

The original request was to allow LaTeX notation for the labels, this
changeset will enable doing that (and more) by installing the additional
`latex-pict` package and using the pictures produced by that package as
labels.

The folowing caveats apply for the implementation:

* the label position for the Y axis **is not** rotated when it is a picture,
  only when it is a string.  This was done to allow full flexibility to users
  who chose to use pictures -- they can easily rotate the picture themselves.
  If the picture would be rotated by the plot package, the user might have to
  supply a rotated picture to have a horizontal picture for the y label, and
  this would result in a double rotation -- depending on the type of graphics
  used for the picture, this might create undesirable artifacts.

* the font used for axis labels and title determines the gap between the label
  and the plot area and axis themselves.

A bug was fixed, where passing incorect parameters to plot procedure could
cause Racket to crash, an explanation for the fix is put as a comment in the
"plot-gui-lib/plot/private/gui/plot2d.rkt" file.

See also:

* racket#58
* racket/racket#3321
* racket#64
alex-hhh added a commit that referenced this pull request Aug 28, 2020
Updated the 2D and 3D plot procedures to accept a picture (from the pict
library) or a string as the label for the `#:title` and`#:{x,y,z}-label``
keywords, as well as the corresponing parameters, `plot-title` and
`plot-{x,y,z}-label`.

The original request was to allow LaTeX notation for the labels, this
changeset will enable doing that (and more) by installing the additional
`latex-pict` package and using the pictures produced by that package as
labels.

The folowing caveats apply for the implementation:

* the label position for the Y axis **is not** rotated when it is a picture,
  only when it is a string.  This was done to allow full flexibility to users
  who chose to use pictures -- they can easily rotate the picture themselves.
  If the picture would be rotated by the plot package, the user might have to
  supply a rotated picture to have a horizontal picture for the y label, and
  this would result in a double rotation -- depending on the type of graphics
  used for the picture, this might create undesirable artifacts.

* the font used for axis labels and title determines the gap between the label
  and the plot area and axis themselves.

A bug was fixed, where passing incorect parameters to plot procedure could
cause Racket to crash, an explanation for the fix is put as a comment in the
"plot-gui-lib/plot/private/gui/plot2d.rkt" file.

See also:

* #58
* racket/racket#3321
* #64
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.

None yet

1 participant