ericpante / marmap

Import, plot and analyze bathymetric and topographic data
32 stars 7 forks source link

xlim is not working with plot #21

Closed IssamHu closed 3 years ago

IssamHu commented 3 years ago

Hi Sir, When I plot with space.pies the plot is not working with xlim:

GCC <- getNOAA.bathy(lon1 = 48 , lon2 = 60,
                     lat1 = 15, lat2 = 31, res = 1, keep = TRUE)
plot(GCC, deep=-8000, shallow=0, step=1000,col="grey", xlim = c(40,70)) 
points(Piedata,pch=19,col="blue", cex=0.5)
space.pies(Piedata[,5], Piedata[,4],
           pie.slices=Piedata[,2:3], pie.colors=Piedata[,6:7], pie.radius=0.8)

The data used: Piedata Country Legal Illegal Latitude Longitude cola colb 1 A 0.375 0.625 29.74247 48.41323 lightblue orange 2 B 0.852 0.148 27.77500 49.14698 lightblue orange 3 C 0.345 0.655 26.31520 50.49300 lightblue orange 4 D 0.562 0.439 25.56074 51.64831 lightblue orange 5 E 0.410 0.590 25.45679 54.72089 lightblue orange 6 F 0.750 0.250 21.11154 59.32937 lightblue orange

pie_marmap_space pies

besibo commented 3 years ago

What do you mean by "it dosen't work"? What do you want to achieve? Please, provide more details and reproducible code. You should help me help you, by providing all the code necessary to reproduce your problem (including the creation of the Piedata dataframe: I should not have to manually copy-paste in a text editor the raw data you provided, then edit it to remove the line numbers, save it and import the data manually in R just to be able to reproduce your problem/graph/example). Next time, please provide a fully reproducible example

You downloaded bathymetric data over a region with a fixed bounding box (from 48º to 60º in longitude and from 15º to 31º in latitude). By setting xlim = c(40,70) you try to set boundaries that go beyond the bathymetric data you downloaded, so you can't expect to get bathymetric information there. This is a perfectly normal behaviour.

If your objective is to restrict the white space on both sides of your plotting region, just resize your plotting window (or, preferably, set the size of your graphic device explicitly (for example with png(width = ..., height = ...). You have to understand that you are plotting geographic data. Hence, by default, marmap uses a fixed aspect ratio (asp = 1) to plot bathymetric data, in order to ensure that one degree in longitude is always of the same length than one degree of latitude. If this doesn't suits you, just use asp = NA. Your bathymetric data will then completely fill your graphic device with no white space one the sides, but depending of the aspect ratio of your graphic device, your map will be (sometimes very) distorted.

In any case, this is all normal behaviour, there is no bug here, and a quick look at the argument list of ?plot.bathy and/or the package vignettes should point you in the right direction.