I'm using the package Plots with the pyplot backend.
By default, errorbars are black. How can I change their color? I want to set it to the same color as the line itself (which should be the default behaviour imho).
using Plots
plot(1:3,1:3,yerr=0.1) # produces a blue line with black errorbars
markerstrokecolor/mscsets the color. Normally you'd put points on the plot as well, rather than just the line with error bars, the default is thus to have the stroke around each point in the same color as the error bar. If you feel that another default is better you'd be welcome to open an issue on Plots.
Related
I often have to use plots mixing lines and points (ggplot2), with the colors of the line representing one variable (here, "Dose"), and the shape of the points another one (here, "Treatment). Figure 1 shows what I typically get:
Figure 1: what I get
I like having different legends for the two variables, but would like to remove the round markers from the color scale, to only show the colors (see legend mockup below, made with Gimp). Doing so would allow me to have a clean legend, with colors and shapes clearly segregated.
Figure 2 (mockup): what I would like
Would anyone know if there is a way to do that? Any help would be much appreciated.
Note: the plots above show means and error bars, but I have the same problem with any plot mixing geom_line and geom_point, even simple ones.
Thanks in advance !
I am currently using the Plots package and have it along with the PyPlot packages installed. With the code
using Plots
y = rand(10, 10)
pyplot()
plt = plot(y, st=:heatmap, clim=(0,1), color=:coolwarm, colorbar_title="y")
I am able to produce this
heat map
My question is how I can change the color gradient from its current setting (coolwarm which corresponds with a transition from red to gray to blue) to a new setting which has a gradient from red to green to blue. Is there some way to create a custom colorgradient and use that as an argument where I have 'coolwarm' in my sample code?
Yes. First of all there are numerous color libraries in Plots. Try clibraries(), then e.g. cgradients(:colorbrewer) or showlibrary(colorbrewer). In addition, you can make your own gradient with e.g. cgrad([:red, :green, :blue]) and pass that as the color argument.
Look at the following picture, I tried to get a heat plot with ggplot2, but there is a white vertical line on it. What happens? Anybody gives me an hint?
Besides, there is a white line on each side of plot, why couldn't the heat plot fill the whole part while the contour fill the whole part?
Lucky! I've sovled the problem with setting an ultra-small left or right margin.
I was wondering if anybody had much experience with the function bplot in R, I am making a 3d plot and the plot works fine. The only thing I want to change is the gradient of colour which you get from drape=TRUE. At the moment it has a single pink colour fading into blue, I really need a third colour in the middle to highlight the central data better as this is the most important for my study, and at the moment in some of the plots I am doing its too difficult to pick out and correlate with the level of y in the colour scale bar.
Does anybody have any idea how to do this?
I need more reputation to post an image of the plot but you can see what I mean in the second image of this thread.
Plot Regression Surface
Many thanks
Aaron
Try adding a colorRampPalette argument to your plot like so:
col.regions = colorRampPalette(colors=c("red","yellow"))(1000)
This will give you a gradient of 1000 shades between red and yellow, You can use any of the R colors in the color ramp, and you can specify more than two e.g.colors=c("red","orange3","palegoldenrod") if you like. You should put this argument at the same place you are putting drape=TRUE
I am trying to get a correct legend for a series of points in a plot, which look like:
plot(c(3,1),pch=21,bg="white",col="black")
points(c(2,1),pch=21,bg="black",col="black")
points(c(1,1),pch=21,bg="dark grey",col="black")
I thought the legend code would be:
legend("topright",legend=c('Point3','Point2','Point1'),pch=c(21,21,21),
bg=c('white','black','dark grey'),col=c('black','black','black'),bty='n')
But apparently I am wrong, because I only get three white points with black boarder. Why isn't this working and what is the correct code?
If you read help("legend") you find out that bg specifies the background of the legend. You need to use pt.bg:
legend("topright", legend=c('Point3','Point2','Point1'), pch=c(21,21,21),
pt.bg=c('white','black','dark grey'), col=c('black','black','black'), bty='n')