R skewed colours when drawing TIFF image - r

I'm trying to plot a GeoTIFF I made in ArcGIS as the background canvas to some maps, but I've hit a wall getting the colours right.
The ArcGIS output:
But the same GeoTIFF - read into R with readGDAL() {rgdal} and drawn with image() - produces this:
I've tried playing around with colour options - e.g. the colour schemes (rainbow, heat.colors, topo.colors, terrain.colors) are severely limited, and grey() produces a uniform grey box of customisable tone!
Most grateful for any advice on how to plot the GeoTIFF's true colours, or alternatively something not too garish.
(The functions I used are literally the forms I've given - no additional arguments or settings)
thanks in advance
Robin

Try reading it with the raster package into a 'stack' (it should have three bands), then using plotRGB from the raster package.
require(raster)
map = stack("mymap.tif")
plotRGB(map)

Related

Creating a 3D "ribbon" style plot in R

I want to plot the recorded path of an object such as a plane or drone in 3d space using R. The plotted path should be represented by a flat “ribbon” whose orientation perpendicular to the direction of travel changes to reflect the roll of the object. In other words, I want to be able to visualize the path and orientation of the object in one "ribbon" as it banks in turns.
As far as as I can tell, a traditional ribbon plot in R won't allow you to change the orientation in a third dimension.
Matlab and Python have functionality for creating quiver plots where arrows may be placed to indicate the xyz orientation of the object at a given point in time along the path. I cannot find any R packages with similar functionality.
I have played with Plot3D, Plotrgl, Plot3Drgl and cannot find a package that has this capability.
Q1: Are there any packages in R that would support this type of plot?
Q2: If there isn't, how can I go about creating this type of plot R?
Below are examples in Python and Matlab for the 3D quiver type plots, as well as an image demonstrating the ribbon concept I am imagining.
https://medium.com/analytics-vidhya/exploring-data-acquisition-and-trajectory-tracking-with-android-devices-and-python-9fdef38f25ee
Example of 3D quiver plot in python
https://github.com/xioTechnologies/Gait-Tracking-With-x-IMU
Example of 3D quiver plot in matlab
This is an example of what the "ribbon" would look like
Thanks for any help!

Cicular contour map using Plotly

I am trying to create contour plots of film thicknesses on a wafer using plotly, but would like the outputted plot to be a circle since it is a wafer instead of the default square. Do I have to somehow overlay a circle on to the plot and then exclude anything outside of it after the plot is generated? I prefer using plotly if possible since it looks nice. I've tried using ggplot as well but for some reason my data doesn't work with it since the x and y coordinates are apparently irregularly spaced. I've searched around but have not seen any results at least using R.
Thanks!

Defining polygon coordinates with a predefined image and plotting in R

Here is what I need: I have an image and want to plot on specific rectangle-shaped parts of it (e.g., imagine having a picture of a chessboard and wanting to fill every square with a different color). I would like to be able to easily specify the coordinates for these parts and take these coordinates into R for plotting.
I don't have any experience with making such plots. I've thought of simply inserting an image into a plot with rasterImage (), then plotting with polygon (), but the task of setting up the coordinates for the polygon function seemed too time consuming - hence the question above.
If you have any better ideas than using a set of coordinates for the polygon function, please share. Any leads or packages suggestions would also be helpful.
thank you. Marko.

igraph: scale plot size according to size of quartz window

I am using the igraph package in R. My problem is that, when plotting my network using the plot() function, it is not changing in size accordingly to when I change the size of the quartz window. Is there a parameter for this, e.g. similar to stretch="Fill" ?
Another option is to save your plot as SVG or PDF, then crop and resize using an editor such as Inkscape.
Given the comment from the help file quoted here, my suspicion is that you are doing things that igraph is not intended for.
"One convenient way to plot graphs is to plot with tkplot first, handtune the placement of the
vertices, query the coordinates by the tkplot.getcoords function and use them with plot to plot
the graph to any R device."
Either set the quartz window size first, or don't use igraph to create your static plot.

rgl plot: point size does not change when saving as postscript

I'm trying to generate a 3d scatterplot using rgl. It looks great on my screen, but whenever I export it as a PDF (or any other postscript format) it completely ignores any size specifications I use.
(I'm running RGui v.2.15.1 and rgl v.0.92.892 on a Macbook under Mountain Lion.)
For example:
library(rgl)
set.seed(1982)
points3d(runif(5),runif(5),runif(5), size=20)
# points look huge
rgl.postscript('testplot.pdf', fmt='pdf')
# points look tiny
Does anyone have an idea for a way to get this to work? The resolution of the images I get using rgl.snapshot don't look so good, and I would really like to get a vector image for this plot.
Also, I followed this thread and I got text to resize just fine, but not points. So I thought one way to work around this would be to plot my points as text using a circle as my character, but I couldn't get rgl to accept symbols or expressions either...
Confirmed on Windows, look like some paper size scaling problem. You might try
spheres3d(runif(5),runif(5),runif(5),radius=0.1)
as a workaround if you can live with real 3d.

Resources