-
Notifications
You must be signed in to change notification settings - Fork 225
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
DOC/Gallery example "Scatter plot with histograms": General improvements #3628
Conversation
# Note that the y-axis annotation "Counts" is shown in x-axis direction | ||
# due to the rotation caused by horizontal=True | ||
projection=f"X2c/{fig_width}c", | ||
# Note that the y-axis annotations, ticks, and label "Counts" are shown in x-axis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Note that the y-axis annotations, ticks, and label "Counts" are shown in x-axis | |
# Note that the y-axis ticks, tick labels, and axis label "Counts" are shown in x-axis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Strickly speaking there are no "tick labels" in GMT but it's called "annotations" 😬.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, but for me the sentence as it was did not describe the content satisfactory. Maybe @GenericMappingTools/pygmt-maintainers have an opinion on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this histogram, the region is set to be region=[ymin, ymax, 0, 0]
, so the vertical axis is the actual X-axis and the horizontal axis is the actual "Y-axis". So, instead of saying:
Note that the y-axis annotations, ticks, and label "Counts" are shown in x-axis direction due to the rotation caused by horizontal=True.
Maybe we should say something like:
horizontal=True
plots horizontal histograms, with X/Y axes flipped. I.e., the X axis is plotted vertically and the Y axis is plotted horizontally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also have to update the histogram tutorial at
pygmt/examples/tutorials/advanced/cartesian_histograms.py
Lines 82 to 85 in 8b6f61d
# Use horizontal bars | |
# Please note the flip of the x and y axes regarding annotations, ticks, gridlines, | |
# and labels | |
horizontal=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated at cead753.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Set plot size. | ||
# The scatter plot is 10x10, and the histograms are 10x3 and 3x10, respectively. | ||
width, height = 10, 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Set plot size. | |
# The scatter plot is 10x10, and the histograms are 10x3 and 3x10, respectively. | |
width, height = 10, 3 | |
# Set the plot size | |
# Here, the scatter plot is 4x8, and the histograms are 4x5 and 5x8, respectively | |
width_scat, height_scat, height_histo = 4, 8, 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the two histograms, their widths are determined by the "height" and "weight" of the scatter plot, and their heights can be any values.
I feel we can just define the dimensions for the scatter plot only, and hardcode other dimensions in the projection
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the changes in 34c8568.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's just an example to show that it's possible to generate such plots with a few lines of extra code I would not overengineer at this point. If someone needs to adjust such plot for own purposes I guess it will be straightforward.
@yvonnefroehlich @michaelgrund In my opinion, this PR now is ready for merging. Please give this PR a final review. |
projection="X10c/10c", | ||
frame=["WSrt", "a1"], | ||
region=[xmin, xmax, ymin, ymax], | ||
projection=f"X{width}/{height}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to skip the unit? If we keep centimeters, we need to update a few other lines (an partly need f-strings).
projection=f"X{width}/{height}", | |
projection=f"X{width}c/{height}c", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more inclined to skip the unit if possible. For projections, it's fine to keep the unit or not, but for other parameters, e.g, xshift
, skipping the unit makes more sense (i.e., xshift=width + 2
, rather than xshift=f"{width + 2}c
.
Co-authored-by: Yvonne Fröhlich <[email protected]> Co-authored-by: Michael Grund <[email protected]>
Co-authored-by: Yvonne Fröhlich <[email protected]>
Co-authored-by: Michael Grund <[email protected]>
Description of proposed changes
This PR contains general improvements of the Gallery example "Scatter plot with histograms":
xshift
andyshift
to make them more flexible (but maybe reduced readability?) Feedback is welcome (:Preview: https://pygmt-dev--3628.org.readthedocs.build/en/3628/gallery/histograms/scatter_and_histograms.html
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash command is:
/format
: automatically format and lint the code