I want to plot to data sets on one canvas. To make one dataset stand out from the other I'll plot it twice using two different characters e.g. a circle around a dot.
Now I want to add this composite character into the legend.
How?
Thank you!
PK
^_^
Related
I'm currently struggling with adding a border line around groups of regions with the same value regarding a specific variable. More explicitly: I plotted US-counties and used col.regions based on their dma_index (variable). The next step would be to add a line surrounding the areas containing counties with the same value of dma_index, i.e. those which are coloured the same (to make it more visible and make comparison with different variables more easy). Is there any way to accomplish this? Thanks a lot in advance!
Similar question to: R mapview: Point border color by group
I have a project where I'm plotting multiple plots with simulation results for different years. Project have grown and more data is needed to be displayed. Because of this I now want to have two legends, but preferebly I don't want to place them in the cornes but rather next to each other in middle. By using coordinates to place the legend this have worked for me in other projects. In this case the x-axis is a date axis and I with that I have had no success in correctly placing the legend box. I need help.
Data is formated with as.Date.
Data is plotted with plot(y ~ x, ...
I have tried
legend(x=as.Date("1992-04-05"),y=110, ...
legend(x=format(as.Date("1992-04-05"),"%Y-%m-%d")),y=110, ...
legend("1992-04-05",110, ...
and some other variants.
Thankful for help :)
To follow up, I found a solution. I didn't find a way to define date-based coordinate to place the legends in the plots, but instead I could place them with legend("topleft",inset=c(0.3,0),.... The inset function allowed me to move the legends into desired positions.
I'm really new to R and i'm trying to group the x axis together instead it being separate like it it and also move the legend.
Graph and Code http://127.0.0.1:41763/graphics/plot_zoom_png?width=1200&height=455
Ran<-table(data$class, data$feeling)
Raw<-barplot(Ran, main="Class Feeling",xlab="Feeling", col=c("darkblue","red"), legend = rownames(Ran), beside=TRUE)
I would help with moving the legend and have the x-axis grouped as one. on the group its two separate, like Great and Great, where i just want one great on the group with the data together by the different times
You can specify legend position and others by using args.legend(). Unfortunately I can't tell you exactly what to do without knowing what data set would looks. However, I think this page might help you.
From the examples of bar graphs I have seen here, the numbers on top of individual bars are those that correspond to the values on the y-axis. I'd like to use another set of numbers or text on a bar graph generated using matplotlib. How can this been done? I' like to use the method shown in:
http://composition.al/blog/2015/11/29/a-better-way-to-add-labels-to-bar-charts-with-matplotlib/
but can't figure out how to refer to a list of labels which might be numbers or text.
After several gyrations, the solution was relatively simple. I passed a list of numbers to the function described in the link above replacing the "height" variable. Also, I prefer to have the bar labels always above the bar, so I just found the largest "y" value and increased the ax.set_ylim to 110% of that value. Not too elegant but meets my needs.
I am writing a script that will generate plots of plot(survfit(Surv(time, event)~factor)).
The different survival curves will have a different color. How is the order of the color defined? is it levels(factor)? unique(factor)?
My point is that I would like to automatically script the legend labels and text. Can I safely I use levels(factor) as legend text?
I am sure this is documented somewhere but the help entry of ?plot.survfit is not very helpful?
Yes, the order of the color depends on levels(factor), and yes, you can use levels(factor) for your legend text.
This applies everytime you are dealing with a factor. There is also a number of functions for you to manipulate the levels of your factor if you need so, e.g. check ?relevel.