I am trying to plot a function in Julia, but keep getting errors. I don't understand what is wrong. The input and output of $\varphi$ is a scalar. I've used x=1530:1545 and still get an error-- can anyone enlighten me? I am very confused.
I am using Julia 0.7.
EDIT:
I got it to work with a slight modification--I changed
x = 1530:1545
added the following two lines
y = t.(x)
plot(x,y)
Why did I have to do this though?
This feature is currently not available in PyPlots.jl, if you would like to have it in the future, your best bet is to file an issue.
However, you can get that functionality via Plots.jl and using PyPlot as a backend.
It would look like this (I'll take a simpler function):
using Plots
pyplot()
start_point = 0
end_point = 10
plot_range = start_point:end_point
plot(sqrt,plot_range) # if you want the function exactly at 0,1,2,3...
plot(plot_range,sqrt) # works the same
plot(sqrt,start_point,end_point) # automatically chooses the interior points
Related
so I am trying to vizualize the prediction of an QDA-learner using the mlr3viz-package in R. The vizualisation (via plot_learner_prediction) works fine, however everytime I try to expand the range of the predictions via the expand_range attribute nothing happens.
pl = plot_learner_prediction(learner, task, expand_range = 3)
Nothing happens when I add or change the expand_range argument. Does anyone know how to handle this argument? I had a look into the documentation https://mlr3viz.mlr-org.com/reference/plot_learner_prediction.html but it doesn't really help me.
Thanks a lot already!
I was looking through some functions and found library(MVN), where I wanted to use the uniPlot function, which is quite neat as it quickly provides summary plots for each column in data frame. I was using :
uniPlot(ready, type="histogram")
But the function was depreciated, I was wondering whether anyone knows anything similar to this function ( plot histograms with overlaying normal curve)?
You can perform this in the current MVN version as following:
mvn(data = iris[1:50,1:3], mvnTest = "royston", univariatePlot =
"histogram")
Having come from Matlab I am struggling to work out why the following does not work:
plot(x=rand(10),y=rand(10))
Produces a graph correctly.
x=rand(10)
y=rand(10)
plot(x,y)
produces error:
ERROR: plot has no method matching plot(::Array(Float64,1),::Array(Float64,1))
I would be very grateful if someone coould explain to me why embeding the code within the plot line produces a result, but defining the variables beforehand results in an error. Logic says they should produce the same result.
I am using Julia v 0.3.1 and have loaded Gadfly as charting tool.
In the first case, you are using keyword argument syntax, not assigning to variables x and y (the meaning of = inside function calls is special). To get the same effect in the second case, you should use
x=rand(10)
y=rand(10)
plot(x=x,y=y)
which passes the value in the variable x in the keyword argument x to plot, and the value in the variable y in the keyword argument y.
In case you didn't. Write this before your code:
using plots
plyplot()
I am looking to automate the process of exploratory data analysis and would like to graph the distribution (using line plots, histograms, density curves, etc.) of all the input variables. As my code stands, I am simply getting 4 blank graphics windows. What am I doing incorrectly? If there is a better approach, I am open to that as well.
mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
for (i in names(mydata)){
qplot(data=mydata,i,geom="bar", fill="admit")
dev.new()
}
This situation looks like one where aes_string would come in handy (along with the addition of print around your call to ggplot). I found this post showing how to use aes_string with ggplot inside a loop.
So it would look something like this:
mydata$admit = factor(mydata$admit)
for(i in names(mydata)) {
print(ggplot(mydata) + geom_bar(aes_string(x = i, fill = "admit")))
}
I'm working in RStudio so have skipped the dev.new part of your code. I found I needed to convert admit to a factor, as well.
I have a question about Reference Classes. My question is in the context of an R package I am developing rCharts. It uses reference classes to create interactive plots from R.
Creating a plot involves a series of calls. Here is an example, where a scatterplot is created at first and then a line plot gets added.
p1 <- rPlot(mpg ~ cyl, data = mtcars, type = 'point')
p1$layer(copy_layer = T, type = 'line')
Now, since a Reference Class is like a closure, I was wondering if it was possible to log the calls made. The idea is that if I can log the sequence of calls made, then I can automagically insert the source code used to create a visualization, along with the html.
I was trying to see if I could make use of sys.function or match.call, but am not getting anywhere. If someone can point me to how I can approach this, it would be much appreciated.
As #hadley stated:
calls <<- c(calls, list(match.call()))
Glad that looks to have worked. Let's get this closed. :)