Plot a range of dataframe columns

Is there way to plot a range of columns using Plots and Dataframes?

I’ve managed to successfully load my text file of data and plot a selection of it (this is using Plots and the new Dataframs 0.11). But is there a way to indicate a large number of dataframe columns?

For example if I have

    using DataFrames, Plots, StatPlots, CSV

    spectra=CSV.read(Filename)

    @df spectra plot(:Freq, [:Mic28 :Mic29 :Mic30])

is there a way to instead select Mic28-Mic30 or the equivalent columns 32-34? (In reality I’m trying to plot more than these three, I have 48 columns to plot at once).

1 Like

Have you tried:

 @df spectra plot(:Freq, cols(32:34))

There is an example of using cols here. The legend doesn’t yet get automatically labelled with the column names but I plan on getting back to that as soon as I have a bit more time. To get the correct legend I think you need to do:

 @df spectra plot(:Freq, cols(32:34), label = names(spectra)[32:34])
1 Like

Thank you! That did precisely what I needed. I had checked the docs for both dataframes and plots but neglected to check those of StatPlots.