Using Plots on data

Let's apply Plots to show a graph on the famous Iris flower data set, which can be found in the Rdatasets package (don't forget to first add this package). We also need the StatPlots package when visualizing DataFrames. It contains an @df macro, which makes this much easier. Here is the code to draw a scatter plot:

# code in Chapter 10\plots_iris.jl 
  using PyPlots, StatPlots, RDatasets 
  iris = dataset("datasets", "iris") 
  @df iris scatter(:SepalLength, :SepalWidth, group=:Species,m=(0.5,     [:+ :h :star7], 4), bg=RGB(1.0,1.0,1.0)) 

We plot the sepalwidth property against the sepallength of the flowers. In the preceding code, iris is the name of our DataFrame, which is passed as the first argument to the @df macro. We then call ...

Get Julia 1.0 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.