It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
everyone, I am not familiar with ggplot2. Now I have questions on it. Here are the codes to produce one plot
data <- data.frame(age=sample(c("25-29","30-34"),100,rep=TRUE),ratio=rnorm(100,mean=1,sd=0.3))
library(ggplot2)
qplot(ratio, data=data, geom="bar", fill=age, binwidth=0.1)
Here are my questions.
(1) How to change the color of histogram?
(2) How to put the legend in the panel?
(3) How to change the background color?
Thanks very much in advance!
Have a look at scale_color_manual, the examples should be sufficient. The general structure of tweaking any scale in ggplot2 is to use the appropriate scale function: scale_{aes_name}_{scale_type}, where aes_name can be color, x, or any other aeshetic, and where scale_type can be continuous, discrete, manual, etc.
Googling for ggplot2 legend position led me to this link. Your answer is in there.
Have a look at ?theme, in particular panel.background. The examples there include an example of exactly what you need.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How do we find the solution of x
say in
2*x=6
using R?
It must be very trivial but I cant find out the appropriate answer.
You can use the solve() function, which can actually handle multiple equations:
solve(2, 6)
The first argument is the left side of the equation, the second is the right side.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to generate an interactive plot with R, for example an xyplot that shows information of the data points on mouseover, and I've read about D3. I would like to be able to write R code to generate the D3 html pages automatically. Is there any R package able to do that?
I've seen there is a r2d3 package on github but I am not sure how far that project is. Any ideas?
Looks to be fairly early in its development: https://github.com/hadley/r2d3. Hadley generally makes announcements when things are ready to test and then puts his packages on CRAN when they are ready for prime-time. (There's also confusion in that some versions of D3 on Github are named r2d3 when they have nothing to do with R): https://www.google.com/url?q=https://github.com/mhemesath/r2d3&sa=U&ei=Ig-YULraMueimQWxhYHgCA&ved=0CAwQFjAC&client=internal-uds-cse&usg=AFQjCNGe9p5iKH6deoHDpd2yKHJds8Qdow
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
By following this thread
I have created a radar chart. Can anyone suggest me how to add a legend to this graph?
Here's a generic legend to get you started. You can alter it to suit your particular needs:
legend(-2,0,
legend=c("V1","V2"),
pch=c(15,16),
col=c("blue","red"),
lty=c(1,2))
The first two arguments are the location of the legend, in terms of the plot's (x,y) coordinates. Check the help for more details on the various arguments to the legend function.
I think you're getting negative votes because you essentially asked others to do your work for you. In the future, try out a few things first to see if you can get at least a partial answer. Then, in your question, explain what you've tried and what, specifically, you're trying to accomplish.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
By points, I mean the points on the bottom of the densityplot. Furthermore, I would like to set some value of "jitter", such that all the points are not just on a straight line and more "scattered" around.
With lattice, it is often helpful to look at the panel version of help functions ?panel.densityplot, which mentions jitter.amount; I admit to peeking at the source for panel.density to see that points are plotted using panel.xyplot, which has argument col.symbol. So
library(lattice)
x = rnorm(1000)
densityplot(x, jitter.amount=.02, col.symbol="red")
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
i assume that we have 2 labeled graphs G and T and the algorithm determine if G a subgraph of T and the corresponding vertices in the main graphT and the subgraph G should have same label
That problem is called "subgraph isomorphism" and it is NP-complete (and so likely to be hard). Do you need a general solution for this, or just for a particular graph G? The second case is much easier. There is some general information about algorithms here. There is a version of one of the algorithms (actually, for a more general problem) in the Boost Graph Library (see documentation here).
A general answer for a general question: the problem you want to solve is known as 'subgraph isomorphism.' Have a look here for further references: http://en.wikipedia.org/wiki/Subgraph_isomorphism_problem .