1

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
Baptiste Merliot
  • 841
  • 11
  • 24

1 Answers1

0

//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

jentek llc
  • 31
  • 3
  • It's been more than one year so I don't bother searching for too long (it may be a good question for another future user though). I was looking for a solution to display charts side by side [like this example with matplotlib in python](https://matplotlib.org/gallery/lines_bars_and_markers/scatter_star_poly.html#sphx-glr-gallery-lines-bars-and-markers-scatter-star-poly-py), more than plotting several curves on the same chart. – Baptiste Merliot Feb 09 '20 at 16:49