I would like to know how to do this kind of graphs using ggplot :
https://image.noelshack.com/fichiers/2019/21/3/1558514850-plot-example2.png
This is an excel graph. I already know how to do each of the two histogram (left and right) but I don't know how to plot the two of them on the same graph, separated on the middle of the graph, with this duality.
Maybe using a specific package or geom I don't know yet ?
Thanks for help
You need to build your histogram with geom_col(), to have positive values for one groupe, négative values for the second groupe, and then use coord_split()
Related
I am trying to plot individual data points on a line plot I already made as follows:
p=plot('3.29*exp(-17.4*(x^2))-0.908',xrange=[0.,1.],yrange=[-1.,1.5])
I first tried overplotting a point like this but nothing appears on the graph
estimate1=plot([0.549],[0.755],overplot=1)
When I give the plot function two points to overplot by adding another set of x and y values in input vectors, it connects them.
estimate=plot([0.349,0.9595],[0.555,0.9995],overplot=1)
How can I (over)plot the points without them being connected?
You should be able to set linestyle = 6 which will plot without the line.
I found a way around the problem I was having. After choosing a symbol for the points I wanted to show, I simply set the transparency of the line connecting them to 100 and the symbol transparency to 0.
estimate1.symbol='diamond'
estimate1.transparency=100
estimate1.sym_transparency=0
The work around is not elegant, but it works.
When plotting a bar graph, for example, using pygal, I'd like to be able to know the number of bars the graph will have, in order to make a decision on whether or not the graph should be plotted.
Is there a way to do this?
Additionally, is there also a way to find out the number of slices in a pygal pie graph, and the number of points in a pygal line graph, before plotting them?
Thanks in advance!
is it possible to "mirror" the y axis with R plotly ? I would like to do something similar to this, but with a mirrored y-axis, in order to plot 2 by 2 some data, one replicate one the regular yaxis, and the other on the mirrored axis (that would prevent me to convert a half of my data to negative values).
Also, if possible, I want the bars to be on the same place (one right under the other), not on two distinct sides like showed in the link.
Thanks in advance.
I'm trying to create a dot chart in Stata, splitting it into two categories
Running a chunk of code:
sysuse nlsw88, clear
drop if race == 3
graph dot (mean) wage, over(occ) by(race)
Creates such output:
So far so good but I'd like to remove labels of Y axis from the right graph to give the data some more space.
The only way I've been able to do that was to manually edit graph and hide the axis label object:
Is there a way to do it programmatically? I do know I could use one more over() but in some graphs of mine that is already taken.
I believe the solution is buried in help bystyle and help by_option. However, I can't get it to work with your example (I'm on Stata 12). But the description is clear. For example:
A bystyle determines the overall look of the combined graphs,
including
whether the individual graphs have their own axes and labels or if instead the axes and labels are shared across graphs arrayed in the
same row and/or in the same column;
...
There are options that let you control each of the above attributes --
see [G-3] by_option --
And also
iyaxes and ixaxes (and noiyaxes and noixaxes) specify whether the y axes and x axes are
to be displayed with each graph. The default
with most styles and
schemes is to place y axes on the leftmost graph of each row and to place x axes on
the bottommost graph of each column. The y and
x axes include the
default ticks and labels but exclude the axes titles.
If for some reason that doesn't work out, something like
sysuse nlsw88, clear
drop if race == 3
graph dot (mean) wage, over(occ) by(race)
gr_edit .plotregion1.grpaxis[2].draw_view.setstyle, style(no)
does (but I don't really like the approach). You can mess with at least the axis number [#] to do a bit of customization. I guess recording changes in the graphical editor and then recycling the corresponding code, may be one way out of difficult situations.
I plotted a single column in R with the code below
plot(datanew$cap)
But what I actually need is that the points on the x-axis should be on the y-axis while the point on the y-axis should be the x-axis. If anyone has an idea on how I can do this, I will greatly apreciate.
Plotting via
plot(datanew$cap)
is basically the same as
plot(seq(length(datanew$cap)), datanew$cap)
You can use this to your advantage by swapping the arguments (or specifiying x- and y-coordinates explicitly):
plot(x=datanew$cap, y=seq(length(datanew$cap)))