Plots.vline! function is not recognized in new Plots version - julia

Has Plots changed something about vline(!)? Today in the newly installed machine I tried:
begin
pyplot()
Plots.plot([57,89])
Plots.vline!([1.25])
end
and got the error quoted at the bottom. The new Plots is v"1.20.0" while on the v"1.19.3" machine it worked fine.
MethodError: no method matching Val{:vline}

Worked for me on Plots v1.21.3, with PyPlot v2.9.0:

Related

GraphPlots Julia - How to add node labels?

I am currently in the process of plotting a directed graphs using Julia. After some time on the internet I came across the GraphPLot package which seems to be doing an ok job.
However, I can't find out how to add node labels! Here is my code and output from the jupyter notebook.
Update:
I tried the suggested method from GitHub
nodelabel = [1:number_vertices(g)]
gplot(g, nodelabel = nodelabel)
But I get a weird error:
LoadError: Must have one label per node (or none)
while loading In[44], in expression starting on line 1
Changing
nodelabel = [1:num_vertices(g)]
To nodelabel = collect(1:num_vertices(g)) solves the issue.

Julia Gadfly error: add_plot_element not found

Using Julia 0.3.10 with Juno as IDE and Gadfly latest one. Tried running a sample code, but got stuck with add_plot_element not defined error message. The last line throws the error. Running on Win8 64bit. I'm sure I'm missing something.
using Gadfly
xs = [0:0.1:pi]
k = layer(x=xs, y=sin(xs))
p = plot(x=xs, y=sin(xs))
add_plot_element(k, Guide.title("Now it has a title"))
First, add_plot_element is modifying, so you need the ! like:
add_plot_element!(k,Guide.title(...))
This function is also not exported from Gadfly, so you would really need to write:
Gadfly.add_plot_element!(k, Guide.title("Now it has a title"))
except add_plot_element! doesn't work on Gadfly layers! It does, however, work on plots. What should work:
Gadfly.add_plot_element!(p, Guide.title("Now it has a title"))
since the layer itself doesn't have Guide.Title elements, but the plot does.

rCharts and highcharts with shiny plot does not update correctly

I've created a custom plotting function for a scatterplot with error bars on multiple series using rCharts. I successfully embedded said plot in a shiny application. The first time it shows everything works fine:
However, if I try to update the plot (e.g. by changing some input) the plot does not change and I get the following JS error message on the browser's console:
TypeError: 'undefined' is not a function (evaluating 'this[b].destroy()')
The strange thing is that if I check the plot object (p) it seems fine, e.g. I can plot it in Rstudio and also get a viable html page from it. I guess the problem is somehow that the old plot cannot be removed properly.
I use rCharts v. 0.4.5 and shiny 0.10.2.1 and I have uploaded an example shiny app to github:
https://github.com/mlist/highcharts_scatterplot_example
As extra dependency you will need to install the packages rjson and foreach. You can then run the app with
runGitHub(repo="mlist/highcharts_scatterplot_example")
```
Use renderChart2 rather then renderChart. Replace output$testPlot with :
output$testPlot <- renderChart2({
p <- highcharts.scatterplot.plate(data.frame(seq(1:nrow(iris)),iris[,2], input$error, iris[,5]))
return(p)
})
You can try the change at:
shiny::runGitHub(repo="johndharrison/highcharts_scatterplot_example")

How do I resolve LoadError while trying to make a png on Windows using Julia Studio and Gadfly?

I'm currently working through this tutorial and I'm having trouble getting the png image to display. This is my program.
using DataFrames
using Gadfly
train_df = readtable("winequality-red.csv", separator=';')
_, count = hist(train_df["quality"])
class = sort(unique(train_df["quality"]))
value_counts = DataFrame(count=count, class=class)
#value_counts
p = plot(value_counts, x="class", y="count", Geom.bar(), Guide.title("Class distributions (\"quality\")"))
draw(PNG(14cm, 10cm), p)
the error I get is
LoadError("C:/Users/John/Desktop/helloworld.jl",12,MethodError(PNG,(140.0mm,100.0mm)))
I've tried some of the things mentioned in this discussion, however I haven't made any observable progress.
I was able to solve my problem by installing Cairo.
Pkg.add("Cairo")
and changing this line
draw(PNG(14cm, 10cm), p)
to
draw(PNG("chart.png", 14cm, 10cm), p)
and then opening chart.png with Julia Studio

Points3D Function in R

I have the scatterplot3d package installed in R. When I load it with library(scatterplot3d) or require(scatterplot3d) I am able to create a 3d scatter plot. However, when I try to use the points3d function I get the following error:
Error: could not find function "points3d"
I tried reinstalling the package to no avail (both inside R and as a tarball using R CMD INSTALL in the command line). I am running Xubuntu 12.10 kernel 3.8.7-030807-generic and R version 2.15.3 (2013-03-01).
Entering locate points3d in the command line gave me no results.
I also tried the par.mar default settings command as explained in the manual.
scatterplot3d does an interesting object-oriented twist on the usual R practice. The object returned from the function call includes the points3d function as built-in part of the object but it is not in the Global environment. It is intended that you add to the existing plot-object using that "attached" function that is not a free-living organism but rather a domesticated animal that only exists in the object corral, so you would use this as your syntax:
object$point3d(x,y,z)
I do "feel your pain" but can show you how to overcome the frustration, since I created a working example yesterday: Using scatterplot3d to plot a sphere
You need to intall the package plot3D in the usual way via
install.packages("plot3D")
Then you just need to import, generate the dataset and use the function points3D()
library(plot3D)
x = rnorm(100)
y = rnorm(100)
z = x + y + rnorm(100,0,1)
points3D(x, y, z, col = rainbow(1000))
This is the plot generated by the code above

Resources