Mapping variable values to colors in gvisLineChart? - r

I'm looking for the equivalent of:
ggplot(df,aes(x=date,y=var1,**group=col1,colour=col1**))+geom_line()
in the googleVis package.
Anyone knows how to do this? I only found examples of differently colored lines if they are mapping different columns from the dataframe.
thanks!

#mtoto, I hope my answer here on ggplot2 equivalent of 'factorization or categorization' in googleVis in R can help. Have you taken a look?
Using roles you can specify specific styles for your data. It involves adding another column with the style detail. So if plotting varx, you need to add the column varx.style where you will set the colors.
I do not know ggplot well enough to know if this is the exact fit of what you want, but please take a look at my figures and links in that answer.

Related

How do I make gsea plot with group names labelled?

I am trying to plot gsea similar to image as given below:
the tutorial does not give you such plots. So I tried the github link.
But it failed to generate the similar plot
I checked both gseaplot2{enrichplot} and plotEnrichment{fgsea} and found no options to automatically add the group names. It might be a good idea to just add the names after exporting to Adobe Illustrator. Would be happy to hear other ideas though if anyone else knows a better way.

plot panel visualization using ggplot2 in R shiny

I am implementing a R shiny with a plot panel implemented by library(ggplot2). If there are 12 plots, the layout looks great. Please check below.
12-plot layout
However, if I increase the plot number to 70, then each plot looks being compressed (pls see below). Is that possible I can keep the size of each plot fixed? Thank you so much!
enter image description here
Is there another way to approach this? For instance, can you group your data by two categorical variables and use on for colouring and the other for facetting? In that way, you may be able to reduce the number of facets, and stick with the larger facet size, while still conveying all relevant information? 70 facet plots is a lot!
Is this more of a QC thing? For QC, I tend to break it into groups by condition as Paul was suggesting. The reason is that within a condition, things should be really similar. Outside a condition, all bets are off. When I do this for genomics data, I tend to use “pairs” customized to my liking.
What don’t you like about the 70 sample display? Simply the change in aspect ratio? IMO, these are the things I don’t like about ggplot. You can make these plots using base R and then place them on a page manually using par or layout. For that matter, you can do the same with ggplot and use ggarrange or a different manual layout function to place the plots. All wrapped in a for or apply of course.
The other things I like to do when I have a LOT of QCs to look through is create a movie. I can use the forward/back buttons and go through a lot quickly. I like the idea of having this in a dashboard, nice one!
you could also try coord_fixed(ratio= ), not sure if that will work with faceting or not
Finally, I have made a movie-like visualization for those 70 plots using the plot_ly function in R package "plotly".

Using ggplot to plot a customizable table of data

This idea has been spurred by this work at Five Thirty Eight.
I'm not entirely sure that they used R, but the chart appears in a similar fashion to their other data viz. I looked around here, but couldn't find anything directly relating to this.
Is this kind of plot possible using ggplot?
Thanks for any and all help!
They do use R but their ggplot2 theme is semi-proprietary and they don't say what they use. People have attempted to recreate the theme
https://github.com/jrnold/ggthemes
After the graphs are created it then goes through an illustrative step to bring graphs together and make them more of a story.

Building a heatmap in R with more information

I made a heatmap on R and most of it is one colour. I have two columns of data which showed up as various colours, but the rest of it is red.
Does anyone know how to increase the "resolution" of this? I don't mean anything about how to make the image more clear (which is why I think I'm having trouble searching for info on it). I mean, how do I make my heatmap more meaningful and not all mostly one colour.
Thanks and sorry if this has been answered somewhere else. I think I don't know the key term I need to search properly.
Edit:
Here is the code I used so far (heatdata is my matrix):
heatmap <- heatmap(heatdata,Rowv=NA,Colv=NA,col=cm.colors(256),scale="row")

Heat Map Histogram with gnuplot

I'm working in Gnuplot, and I have a graph looking roughly like the following:
If I want to have the color of the line change color depending on the curves's values, what's the most straightforward way to make that happen?
Thanks!
Does the answer to this question help?
For example:
plot "./file.dat" u 1:2:2 with lines palette
where file.dat contains your data, the first column is the x axis and the second column is the y axis.
The repetition of the 2 indicates that the second column is also used for the colour.
I know there is a function (which i use quite a bit) on the matlab file exchange by Ken Garrard called plot3k that has this functionality that you're looking for. Mayhapes you could have a look at the implementation for hints for a gnuplot port.
Maybe these three articles is helpful:
http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot0.html
http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot1.html
http://gnuplot-surprising.blogspot.com/2011/09/gradient-colored-curve-in-gnuplot2.html

Resources