-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
force-pushed
the
ah/pict-labels
branch
from
August 14, 2020 06:23
b77edbe
to
ef0aea3
Compare
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updated 2D and 3D plot renderers to accept a pict 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 ofplot-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