Fixed width and height frame

Can we fixed widht and height frame like arcgis? So, if region larger or smaller, widht frame dont change

Do you mean the region (-R) or the dimensions (-J) of the plot?
For the latter, see e.g. 6. GMT Map Projections;

  • (detault is +dw)
  • Append +dh to the given dimension to specify map height.
  • Append +du to the given dimension to select the minimum map dimension.
  • Append +dl to the given dimension to select the maximum map dimension.

I have boundary region, like lonmin/lonmax/latmin/latmax. How to fix width and heigh to draw in canvas. Because, if we draw different boundary (larger or smaller), widht and height do change

Sounds like you’re using scale instead of width [default], e.g. -Js and -JS respectively.

Need to see some code to be able to help more.

This is a piece of my code. So, i want to read boundary from input data. So, I have dynamic area. I want to plot with grdimage in my canvas with widht 26 and height 11.5. How to do that?

latmin = df[(df[9] == df[9].min())]
latmax = df[(df[9] == df[9].max())]
lonmin = df[(df[10] == df[10].min())]
lonmax = df[(df[10] == df[10].max())]

region = [lonmin.iloc[0][11]-5, lonmax.iloc[0][11]+5, latmin.iloc[0][10]-5, latmax.iloc[0][10]+5]

fig.grdimage(grid=grid, cmap=“bati_oceanworld.cpt”, yshift=“3.2c”, xshift="-0.4c", projection=“Q10i”, frame=[“ag”,“WSNE”, “xaf”], shading=“”)

Sorry, I see now that this is PyGMT - I do not use that (yet), so I’m having trouble helping you.

Dont worry, I will convert them to pygmt. In gmt, how to do that?

For a map of Denmark with the Mercator projection:

  • fixed width (default, +dw is implicit): $ gmt pscoast -RDK -W -Bafg -JM10c+dw -png dk
  • fixed height (-dh): $ gmt pscoast -RDK -W -Bafg -JM10c+dh -png dk

Hello @ankara17,

thanks for providing your code!

Based on my current understanding of your question, I feel what you want to do is not possible. If you state the width of the map together with the region and projection, the height of the map will be determined by these values and can not set be freely anymore.

if I only use projection how to do that? So, the projection will approach widht and height

If I want to fixed widht and height, may I?

I don’t think you can do that with a projection.

If you have projected data, you could plot it as cartesian and force a width/height with e.g. -JXwidth/height, I think. But your plot may look ‘stretched’ by doing this.

Other idea:

Plot your map with desired scale
Overlay basemap with desired size
Adjust the region to « fill » the blank spaces

Just to be clear, you want a fixed map dimensions (26 c x 11.5 c) and a approximate region (anyone that include all your data), right? Could you give us an example of the map that you want to make.

I think that mapproject -W could help you.