Log scale for contour plot in Plots.jl - julia

Is it possible to use a log scale in a contour plot? The plot should look like contour(log10(data)), but with correct labelling of the colorbar.

Related

legend outside plot in R and use pty="s"

I want to plot a roc curve in R but with legends outside the plot.
I want the axes labels to be from 0-1. So I used pty="s" but I am trying to fit the legend its not working.
par(pty="s",xpd=T, mar=par()$mar+c(0,0,0,3))
plot(g1,main="BPH vs G6", lty=1,xlab="Specificity", ylab="Sensitivity",
lwd=2,cex.main=2,font.axis=2,font.lab=2,cex.lab=2,cex.axis=1.2)
lines(g2, lty=1, col="red", lwd=2)
legend(-0.1,0.8,
legend=c("301+CN","CN"),
lty=c(1,1),col=c("red", "black"),cex=0.5)
I do not want the diagonal line to go outside the plot. Also, I want to increase the legend size, but by adjusting cex its not fitting here.

Shading lines ggplot2

Does anyone know how to add shading lines in an area or histogram plot in ggplot2?
For example, How could I reproduce the following plot in ggplot2 ?
hist(mtcars$hp, density = 10)
Thanks.

how to plot countour curve on top of scatter plot in Octave

I am using Octave plot() function to plot scatter points on a 2D graph. And then I am using the contour() function to draw a contour on top of the points. But the contour() function is not overlapping on top of the points. What happens is that the scatter plot graph is replaced entirely with the contour, even though I am using the HOLD ON command.
I have something like this:
plot(); %plot the x,y scatter plot
hold on; %hold on to be able to add to the plot
contour(); %Add the contour on top of the scatter plot
I wonder if someone can show some sample code they can show to add a contour to an existing plot.
thanks
Here is an example :
x = [-10:0.1:10];
y = x .^ 2;
z = x' * x;
hold on;
contour(x,y,z);
plot(x,y);
Will yield this graph (in blue you can see the parabol issued by plot).

R plot and barplot how to fix ylim not alike?

I try to use base R to plot a time series as a bar plot and as ordinary line plot. I try to write a flexible function to draw such a plot and would like to draw the plots without axes and then add universal axis manually.
Now, I hampered by strange problem: same ylim values result into different axes. Consider the following example:
data(presidents)
# shorten this series a bit
pw <- window(presidents,start=c(1965))
barplot(t(pw),ylim = c(0,80))
par(new=T)
plot(pw,ylim = c(0,80),col="blue",lwd=3)
I intentionally plot y-axes coming from both plots here to show it's not the same. I know I can achieve the intended result by plotting a bar plot first and then add lines using x and y args of lines.
But the I am looking for flexible solution that let's you add lines to barplots like you add lines to points or other line plots. So is there a way to make sure y-axes are the same?
EDIT: also adding the usr parameter to par doesn't help me here.
par(new=T,usr = par("usr"))
Add yaxs="i" to your lineplot. Like this:
plot(pw,ylim = c(0,80),col="blue",lwd=3, yaxs="i")
R start barplots at y=0, while line plots won't. This is to make sure that you see a line if it happens that your data is y=0, otherwise it aligns with the x axis line.

Having spectral density without plot

I want to have spectral density of a set of values
x.spec<-spectrum(datalist[1:128,1],log=c("no"))
this code plot form me a plot. but I dont want to have any plot. Is there any way, that I can ignore this plot and having only spectral density
x.spec$spec
x.spec<-spectrum(datalist[1:128,1],log=c("dB"),plot=FALSE)

Resources