I'm looking at the Julia package "DifferentialEquations.jl", a differential equation solver package in Julia. In the tutorial page , there is an example solving the Lorenz equations and plotting the Lorenz butterfly. To plot the Lorenz butterfly, the command used is
plot(sol, vars=(1,2,3))
I understand roughly that the "vars" specifies the data used as the 3 axes. However, I never found this "vars" in the documentation of "plot", or of "DifferentialEquations.jl". What is it logically? Seems the function "plot" has many keys but "vars" is not one of them.
Any idea where I could find it?
For example, if I try:
t=[0.0:0.1:2*pi;]
points = [sin(t), cos(t)]
plot(points, vars=(1,2))
it doesn't work.
It is defined in DifferentialEquations.jl - the package has used what we call a "recipe" to overload Plots' plot function to take a new keyword if the object passed to plot is a Solution. You can find the DiffEq-specific plot keywords documented here: https://diffeq.sciml.ai/stable/basics/plot/
Related
I have constructed a model of svm on a dataset of Fraud transactions , but when I am trying to plot the model it is neither showing any error nor showing any plot. My code is -
>library(e1071)
>attach(FraudTransData)
>model2<- svm(FraudTransData$Fraud_Ind~., data= FraudTransData)
>plot(model2, FraudTransData)
I used the same plot function on another dataset cats and it showed a successful plot. I am unable to understand where have I gone wrong.
How many inputs do you have?
The code you wrote does not work if you have more than two. You should add arguments formula and slice in the plot function.
Check the 'iris' example at help(plot.svm)
I want to plot a graph for an exponential function but I am completely lost as i have never previously used matlab or scilab.
I have been researching a bit and now know how to plot linear functions, but I don't know how to plot the exponential function. I tried and kept getting errors such as "inconsistent row/column dimensions". The equation is
Here is how to do what you want on [0,1]. The errors you get are likely due to missing dot in product operator:
t=linspace(0,1,1000);
plot(t,2-2*t.*exp(-t)-2*exp(-t))
I am trying to fit my data using the fitdist() function from the fitdistrplus package in R. I succeeded using a normal and a lognormal distribution via key words 'norm' and 'lnorm' which I found via searching online.
I was not able to get other distributions working; the help of fitdist() says:
distr: A character string "name" naming a distribution for which the corresponding density function dname, the corresponding distribution function pname and the corresponding quantile function qname must be defined, or directly the density function.
I checked and when entering ?norm or ?norm into the R command line, neither function norm() nor lnorm() is found. This confuses me totally.
When I try for example fitdist(data, 'poisson'), I get the following error message:
Error in fitdist(data$time, "poisson") :
The dpoisson function must be defined
I am somewhat a noob in R, can anybody give a hint?
norm() in R is a different function to compute norms of a matrix, so not directly related to the normal distribution.
?Normal brings up the documentation related to the normal distribution, and you'll see the 4 functions dnorm, pnorm, qnorm and rnorm belonging to this family.
If you look at ?Lognormal you'll see the same convention with the typical 4 functions.
More generally, you can look-up ?Distributions, which links all of them. There you can see that the keyword for the poisson distribution should actually be pois.
I'm confused about the mechanics of R (crossover from python). For example, I find best subsets with regsubsets (this is a class from a library called "leaps") and then plot below:
regfit_full = regsubsets(Something~.,data = db)
plot(regfit_full, scale="r2")
How does plot know how to deal with my instance of regsubsets class? Does plot have first look for a plot method in regsubsets first tells it how? And if this is the case, this second part confuses me. In order to look up documentation I do ?plot.regsubsets. If plot is a method of regsubsets, why is it not ?regsubsets.plot or something?
Thanks for the help
plot() is a generic function in R which dispatches to the "correct" version based on the class() of the first parameter. All the "special" methods for plot can be found with methods(plot).
You can learn more about is in the Advanced R OO field guide
I am using the ABC package in R which computes several statistics that can be plotted. Using
plot( the results as matrix from another function in the package ) or
summary( the results as matrix from another function in the package )
several plots/statistics are displayed.
I am interested to get the maximum value of one of the graphs that is displayed. However, the values of the plotted graphs are not returned or used in the input matrix.
How can I get them, or how can I see what function was applied to construct the graph?
Generally, to view the code for S3 methods, you would type the generic method, followed by a dot. followed by the S3 class. For example, to view the code dispatched on a glm object by the method summary:
summary.glm
Same rule applies for the abc package, however it seems that the authors have not exported their methods into the namespace. Thus, you have to specify the abc package namespace. Try:
abc:::summary.abc
abc:::plot.abc
abc:::hist.abc
for summary(), plot(), hist(), respectively.
As Joshua notes, the str() function is helpful to view how data is stored in an object. For example, after running example(abc) to generate the examples from the abc vignette, the object lin2 is produced, which is of class abc. Trying str(lin2) shows how the data is stored. Then if you wanted to see the adjusted values for lin2, you could try lin2$adj.values.