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

Let inset begin optionally take -R -J to determine inset size instead of via -D #5903

Merged
merged 4 commits into from
Nov 1, 2021

Conversation

PaulWessel
Copy link
Member

See #5875 for background. Normally, gmt inset begin is called without an explicit -R -J and instead it picks those up from the main figure history file that it is setting up an inset for. In that case, users must specify the inset size via -D...+w. However, there are times when the user wishes to specify the inset size indirectly via the -R -J settings that will be used within the inset itself. This PR implements that suggestion and adds a new test inset2.sh to demonstrate its use.

See #5875 for background.  This PR implements that suggestion and adds a new test inset2.sh to demonstrate it.
Add original for inset2.sh test
@PaulWessel PaulWessel added the new core module feature PR that implements a new core module feature label Oct 25, 2021
@PaulWessel PaulWessel added this to the 6.3.0 milestone Oct 25, 2021
@PaulWessel PaulWessel self-assigned this Oct 25, 2021
@PaulWessel PaulWessel changed the title Let inset begin take -R -J to determine inset size Let inset begin optionally take -R -J to determine inset size instead of via -D Oct 25, 2021
Copy link
Member

@maxrjones maxrjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Is it possible to show annotations for inset maps? For example, below the -Ba does not impact the inset map:

gmt begin
    gmt figure test-inset png 
    gmt grdimage @earth_relief -R-51/-48/-24/-23 -JM15c -B -Cworld
    gmt inset begin -DjBL+o0.1c -F+p1p,black -R-80/-28/-43/10 -JM2c
        gmt coast -Wthin -Swhite -Ggray -Bafg -BwsNE
    gmt inset end
    gmt figure test png
        gmt coast -Wthin -Swhite -Ggray -Bafg -R-80/-28/-43/10 -JM2c -BwsNE
gmt end show

@Esteban82
Copy link
Member

Esteban82 commented Nov 1, 2021

Is it possible to show annotations for inset maps? For example, below the -Ba does not impact the inset map:

I think that annotations fall outside of the inset. The issue is that the width of the inset is the same of the map. So the inset should take into account the extra space.

PD: I am not completely sure. Maybe this was already fixed.

@Esteban82
Copy link
Member

I test it with ex 44 but with GMT 6.2 (not dev version) where I use -Baf

ex44

gmt begin ex44 png 
	gmt coast -R10W/5E/35N/44N -JM15c -EES+gbisque -Gbrown -Wfaint -N1/1p -Sazure1 -Dh --FORMAT_GEO_MAP=dddF
	gmt inset begin -DjTR+w5c/2.35c+o0.4c/0.25c -F+gwhite+p1p+c0.1c+s
		gmt coast -R15W/35E/30N/48N -JM? -Da -Gbrown -Bafg -EES+gbisque --MAP_FRAME_TYPE=plain
	gmt inset end
gmt end show

@PaulWessel
Copy link
Member Author

When -R -J is used with gmt inset you get exactly that size and that is the projection you have in the inset. So the only hope would be to add a margin to the inset dimensions I think.

@PaulWessel
Copy link
Member Author

This all depends on annotation size etc but you can slap a -M2p/14p/2p/14p to that inset call and play with the numbers.

@Esteban82
Copy link
Member

This all depends on annotation size etc but you can slap a -M2p/14p/2p/14p to that inset call and play with the numbers.

Ok.

BTW, what is the default units for -M? inches? I noticed that it is not clarified in the docs.

@PaulWessel
Copy link
Member Author

Should be cm like any other dimensions (only exception I think is font sizes which are assumed to be in points).

@PaulWessel
Copy link
Member Author

It seems like a lot of work to get a nice tiny inset with annotations, e.g.:

gmt begin test-inset png 
    gmt coast -R-51/-48/-24/-23 -JM15c -B -Gpink
    gmt inset begin -DjBL+o0.1c -F+p1p,black -R-80/-28/-43/10 -JM2c -M3p/9p/3p/7p
        gmt coast -Wthin -Swhite -Ggray -Bafg -BwsNE --FONT_ANNOT_PRIMARY=4p --MAP_FRAME_TYPE=plain --MAP_FRAME_PEN=0.5p --MAP_TICK_LENGTH_PRIMARY=2p --MAP_ANNOT_OBLIQUE=lat_parallel
    gmt inset end
gmt end show

I guess I think that insets showing the entire world or a large chunk of it may not really benefit much from having separate annotations. Do we really need to know that South America has these coordinates, when the main plot has the coordinates for the data we actually are presenting? Perhaps a personal choice but I would not bother to add tiny tick marks, tiny fonts etc and worry about it all fitting. But, as you see, you can if you want to.

@maxrjones
Copy link
Member

It seems like a lot of work to get a nice tiny inset with annotations, e.g.:

gmt begin test-inset png 
    gmt coast -R-51/-48/-24/-23 -JM15c -B -Gpink
    gmt inset begin -DjBL+o0.1c -F+p1p,black -R-80/-28/-43/10 -JM2c -M3p/9p/3p/7p
        gmt coast -Wthin -Swhite -Ggray -Bafg -BwsNE --FONT_ANNOT_PRIMARY=4p --MAP_FRAME_TYPE=plain --MAP_FRAME_PEN=0.5p --MAP_TICK_LENGTH_PRIMARY=2p --MAP_ANNOT_OBLIQUE=lat_parallel
    gmt inset end
gmt end show

I guess I think that insets showing the entire world or a large chunk of it may not really benefit much from having separate annotations. Do we really need to know that South America has these coordinates, when the main plot has the coordinates for the data we actually are presenting? Perhaps a personal choice but I would not bother to add tiny tick marks, tiny fonts etc and worry about it all fitting. But, as you see, you can if you want to.

Good to know that it's possible, thanks.

@PaulWessel
Copy link
Member Author

Any other concerns before we merge this one?

@maxrjones
Copy link
Member

Any other concerns before we merge this one?

Looks good to me.

@PaulWessel
Copy link
Member Author

I just addressed @Esteban82 comment on units for margins in both inset and subplot.

@Esteban82
Copy link
Member

Looks good for me too.

@PaulWessel PaulWessel merged commit 2cf8546 into master Nov 1, 2021
@PaulWessel PaulWessel deleted the inset-RJ branch November 1, 2021 21:19
@Esteban82
Copy link
Member

It seems like a lot of work to get a nice tiny inset with annotations,

I think it would be good to have an easy way to do this. I agree that is has no much sense for insets. But I think it could be good to set the dimensions of canvas in movies. In some occasions, I just want to get the animation and I don't care about the final dimension of the canvas.

@PaulWessel
Copy link
Member Author

Could you explain this differently? I do not understand what you mean related to canvas and movies. You mean not specifying -C and let it be found from main.sh as the dimensions of the cropped frame? You would have to specify dpi though, right? So if you gave -C100c you want a 100 dots per cm movie frame of whatever size that is given your script? This would mean (1) need to run main once to call psconvert and determine the bounding box size, then (2) have to assume all frames are the same size.

@Esteban82
Copy link
Member

Yes. Like with any figure. I define the map width, I then add some stuffs like annotations and colorbar outside the map and finally psconvert gives me the bounding box size (which is slighter bigger than the original width).

@PaulWessel
Copy link
Member Author

And what about dpi? Via -C, or default to the same as psconvert [300i]? Probably would give 4k-size movies...

@Esteban82
Copy link
Member

Mmm, I haven't think about dpi. The default 300 dpi sounds good. Or maybe with -C?/?/dpi??

@PaulWessel
Copy link
Member Author

I think -Cdpi is enough for that. If you compose on a typical piece of paper (say make a plot around 24x13cm which is the HD format setup now) then 300 is pretty large. The current scheme is 80dpc or 200dpi:

1080p: 1920 x 1080 24 x 13.5 cm 80.0000 9.6 x 5.4 inch 200.0000

But, I think it is still the best default since it is what GMT_GRAPHICS_DPU currently is set to.

So to get this to work, post 6.3, would be to

  1. Detect that user only give a dpi, or none at all (no -C meaning -C300)
  2. If so, give a warning that we will determine the canvas size from the main script
  3. Before we get to the main loop, run frame 1 once and get the bounding box from that one plot
  4. Set the -Cwidth/height parameters accordingly and continue the run

One issue is the pre.sh script which may need to run to create data to even run the movie, and it may also create a background PostScript plot. That plot needs to know the canvas size too, which we don't know yet. SO it gets a bit messy in having to run it twice.

@Esteban82
Copy link
Member

Ok. Sounds good. I think that might be an issue with for the bounding box for the animation 03.

@PaulWessel
Copy link
Member Author

Right, so it cannot work for those types of animations, only the static frame one. Which begs the question if all the above work is really worth the effort...

@Esteban82
Copy link
Member

I think so. I will definitely use it.

@maxrjones maxrjones added the add-changelog Add PR to the changelog label Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-changelog Add PR to the changelog new core module feature PR that implements a new core module feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants