Plot multiple vegas charts in the same window

523 Views Asked by At

I am using vegas on IntelliJ to plot charts from Spark dataframes.

Since I am not using a notebook like Jupyter with Toree, my charts are displayed on separate windows, which is quite annoying when I have to plot 20 of them.

I would like to know if there is a way to make a subplot like in Matplotlib in python. Should I definitely use a notebook instead?

Here is my code in Scala, where histogram is a dataframe with 2 columns : cube and count:

Vegas("Histogram").
    withDataFrame(histogram).
    encodeX("cube", Quantitative, scale = Scale(ScaleType.Log), title = "cube " + name).
    encodeY("count", Quantitative).
    mark(Bar).
    show
1

There are 1 best solutions below

1
jentek llc On

//Following is what I did in my use case, for your reference only Vegas.layered("linear regression",width=600, height=300). withLayers( Layer(). withDataFrame(df). mark(Point). encodeX("features", Quantitative). encodeY("label", Quantitative), Layer(). withDataFrame(df_pred). mark(Line). encodeX("features", Quantitative). encodeY("prediction", Quantitative)
). show

Following is the output, that has scatter plot and straight line in the same chart windows.

Scatter and line are on the same chart window