I want to zoom in a particular region of the sky, and plot a map of only that region (e.g., the cold spot). How can I do this with healpix? I could not find options with mollview...etc.
try using gnomview: you can choose the center coordinates (with rot) that you want to plot and a size in x and y (xsize and ysize). This will render a gnomonic projection of the part of the sky you are interested in.
Related
I need to plot some potential energy curves. I.e. I need to be able to create graph looking like this:
Using the tutorial I'm able to recreate curves, create the legend etc. What I'm not able to do are the dissociation limits (labels on the right side of the picture in the red rectangle). Is there any way to make such "independent labels" at certain points on y-axis or do I have to create them like many little plots?
The easiest (albeit time-consuming) way is to use the "Window -> Drawing objects..." facilities and draw everything yourself by hand. Labels can be added with the "Text" button. Note that your life can be a made a bit easier by selecting "Position in: World coordinates" instead of "Viewport coordinates" and adding the real x and y value of each label.
I want analyse the climate data in several cities and for each city a chart is produced using ggplot2. And as underlayer I made a map and want to locate the chart for each city in the map with the right position. I think it is not possible to plot them directly with ggplot2, unless I define a new geom. A better way may be using the Grid package and place the viewports in the right way somehow, that means the viewport center should be set to the precise place with longitude and latitude. Is it possible to use the coordination of another viewport(here the map plot)?
I want to plot a simple outline of a country map and have an area between two latitudes shaded grey.
I think I need to use the rworldmap library but I'm not exactly sure how to achieve what I want.
Good suggestions by others. I initially thought that you might want the latitudinal shading to extend beyond the country borders. If that's the case here's a quick and dirty solution using rworldmap for the map, sp to plot it and polygon from base graphics to add the latitude shading. You could then modify using spTransform from rgdal if you want to project, or the suggestion from Sam if you want to crop to country borders.
library(rworldmap)
library(sp)
sPDFworld <- getMap(resolution="low")
#getMap() maps have ADMIN & NAME fields with country names formatted differently
#use sPDFworld$ADMIN sPDFworld$NAME to check
country <- "United Kingdom"
#to plot just this country (uses sp)
plot(sPDFworld[ sPDFworld$ADMIN==country, ] )
#shade a latitude region
polygon(x=c(-180,-180,180,180),y=c(55,60,60,55),col=adjustcolor('grey',alpha.f=0.5),border=NA)
I'd do something as in https://stackoverflow.com/a/13986029/1358308 . You can crop down to your "rectangle" as needed and then just plot the interiour of the resulting polygon as "grey", and don't print the borders by setting them to NA.
If you plot this "after" the larger outline (using the same polygon, before doing the intersection) then you should just get the country filled in. If you want the "water" filled in using a different color, you can do this "first". The later plot(x, add=TRUE) will plot the new things "on top" so you won't see the working behind.
Hope that makes sense!
Using R: I'm looking to add a world map to my existing plot but I am having issues. My existing plot shows sea surface temperatures of the pacific ocean so I need to essentially shift the world map from the traditional Atlantic view to a pacific view.
When I add the map, it is not aligned with my existing plot of world-wide Sea Surface Temperatures. I need the landmass to align with the white spaces on the map. (you can see the map by viewing the link below)
I've been using map() from the library maps. The lat-long that my existing plot is based on are decimal degrees. I have tried xlim and ylim arguments in map()- they haven't seemed to do anything. I haven't played around with coordinate systems though- mainly because I don't know what to try. Any suggestions? My code is at the link below.
http://rpubs.com/redi1102/9930
The section I specifically am asking about is this:
image.plot(xlong,ylat,zmat,ylim=range(-60,80))
contour(xlong,ylat,(zmat),ylim=range(-60,80),add=TRUE,nlev=6,lwd=2)
world(xlim=c(-150,150), ylim=c(-60,80),add=T)
Thankyou!
I just discovered ggmap and I've been playing around with plotting earthquake data from the USGS. I get the data in the form of Lat and Lon, depth and magnitude. I can easily plot the earthquakes as points with different colors based on depth but what I would like to do is take that depth data (just a single number) and generate contours to overlay on the map.
This seems like it should be MUCH more simple than the "Houston Crime" example I keep coming up on since I'm not doing any statistical "density" calculation or anything like that. Basically it's just a contour map on top of the google map of an area.
How do I do this (Presumably) simple, simple thing?
Thanks!
The problem of plotting a 3D surface using only a small sample of unequally spaced lat/long points and a height z (or equivalent) variable is non-trivial -- you have to estimate the values of z for all of the lat-long grid coordinates you do not have, for example using loess() or kriging to create a smooth surface.
Take a look at Methods for doing heatmaps, level / contour plots, and hexagonal binning, case #5. For a geoR example see http://www4.stat.ncsu.edu/~reich/CUSP/Ordinary_Kriging_in_R.pdf