space points in a scatter plot in R - r

I am plotting a scatter plot in R, however I have many data points and they overlap. I want to have a plot where there no overlaps and maintain a reasonable size of the data . This is the image of the scatter. On the top side is where the data are clustered.
This is the code plot(data2,col="red",pch=21,cex=0.7)

Could you put a reproducible code to check.
One thing you can do is may be increase the space between y axis interval.

Related

Resizing plots in plotly (R)

Sorry if this question has already been answered but I can't find a solution.
I have a data frame which is imported from a .csv file. It has four columns. I want to plot a 3d scatter plot of the first two columns against the last column using Plotly.
The problem is that for some reason, the scatter plot does not automatically resize its axes to fit the plot space. So in this case I end up with a tall thin plot. The weird thing is that if I do an example with some random numbers, I don't get this problem.
Can anyone help me to get my scatter plot to fit to the window?
My data can be found at https://www.dropbox.com/s/ojwrezjker33x2b/Data.csv?dl=0
Basically I want to do:
library(plotly)
X<-read.csv("Data.csv")
plot_ly(x=X[,1],y=X[,2],z=X[,4],type='scatter3d',mode='markers')
And this results in a tall and thin scatter plot (sorry can't post an image cos I am new to the site).
I would like this to be a well-proportioned scatter plot that fits the window.
Thanks for any help.
The default setting for aspectmode is 'auto' and Plotly will try to keep the relative axis lenghts equal.
If you set aspectmode='cube' you should get a plot with identical absolute axes lengths.
plot_ly(x=X[,1],y=X[,2],z=X[,4],type='scatter3d',mode='markers') %>%
layout(scene=list(aspectmode='cube'))

Plot same plot again (or choose which plot to draw)

I have a complex layout of plots, say for example
layout(matrix(1:2,nrow=1), widths=c(1,7))
I have drawn earlier plots, and am now working on a particular plot (e.g. working on the code on the plot). I redraw the plot often to see impacts of changing e.g. margins.
How can I avoid that each time I redraw the plot it moves on to the next plot in the layout?
e.g. each time I have to start from the beginning, call dev.off, call layout, plot the earlier plots, and then start again with my plot.
Can I just select which plot in the layout I want to plot? Can I move the "counter" that selects which plot is being plotted next?

qcc pareto.chart: bars are squashed - how to adjust the y axis?

I've produced a pareto.chart using the QCC package in R. In the default plot, the Y axis is scaled too large & for that reason the bars are too small. Most of the plot is wasted to empty white space. I assume this is a result of the long tail (right-skew) in the data ?
How is it possible to re-scale the Y-Axis so that the bars of the chart will be taller and more prominent (and differences between the bars more visible) ?
This is my first question and I can't post images yet. Please follow the link to an illustration of the problem:
https://www.dropbox.com/s/t8bwhmoxmwl1aic/pareto-axis.png
Thanks!
Keith
If you type help(pareto.chart) you will see there is an option ylim to specify the limits if the y-axis. If you provide some sample data I could try it out.
Otherwise, try including in your function call
pareto.chart(..., ylim=c(0,10000))
and see if that rescales your y-axis.

ggplot - specify coordinate in middle of plot, regardless of scale

I would like to add a rectangle to my scatter plot to specify a region. I know I can do this by calling geom_polygon and specifying the X- and Y-coordinates of the corners. However, I would like to make sure the rectangle is always half (or another fraction) of the height of the plot, regardless of what the scale of the points on the plot is.
Is there any way I can specify the coordinates of the corners with something like "fraction of plotting region" as the unit?
The only other option I see is to try to predict the scale of the plot by looking at the min() and max() of the points that I am plotting and then calculating the coordinates for the box based on that, but that becomes a lot more complicated once you start faceting and so on...

stop ggplot2 from dropping data points outside of axis limits?

If I make a line plot (a time series, for example) and set my axis limits, I want the line to continue off the plot when points are outside of the axis limits, and then come back into the plot for the next point that is within the axis limits. Right now, it seems that ggplot2 will just drop the points completely and give me a an "Error:" message.
If you limit your axes by reducing the axis scale (scale_x_continuous(limits=...)), then that is the expected behavior. By adjusting the scale, you are defining what data should be part of the plot. If you want to use all the data, but just zoom in on a particular region of the axes, you want to use coord_cartesian(xlim=..., ylim=...) instead.

Resources