Plotting multiple lines using XChart
Code: "xchart_lines.py". Programming language: Python DMelt Version 3. Last modified: 04/05/1977. License: Pro
https://datamelt.org/code/cache/xchart_lines_6653.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from org.knowm.xchart import SwingWrapper
from org.knowm.xchart import XYChart
from org.knowm.xchart import XYChartBuilder
from org.knowm.xchart import XYSeries
#import org.knowm.xchart.XYSeries.XYSeriesRenderStyle
#import org.knowm.xchart.XYSeries.XYSeriesRenderStyle
from org.knowm.xchart.style.Styler import LegendPosition
from org.knowm.xchart import VectorGraphicsEncoder;
from org.knowm.xchart.VectorGraphicsEncoder import VectorGraphicsFormat;

def getChart(name):
  chart =XYChartBuilder().width(800).height(600).title(name).xAxisTitle("X").yAxisTitle("Y").build() 
  chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
  chart.getStyler().setAxisTitlesVisible(False);
  #chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.getXYSeriesRenderStyle().Area);
  #Series
  chart.addSeries("a", [0, 3, 5, 7, 9],[-3, 5, 9, 6, 5]);
  chart.addSeries("b", [0, 2, 4, 6, 9],[-1, 6, 4, 0, 4]);
  chart.addSeries("c", [0, 1, 3, 8, 9], [-2, -1, 1, 0, 1]);
  return chart

# Area Chart with 3 series
chart = getChart("Area");
SwingWrapper(chart).displayChart();
# Save it
VectorGraphicsEncoder.saveVectorGraphic(chart, "Area", VectorGraphicsFormat.PDF);

You see the box below because you did not login.