line_chart


This function shows a multiple lines in single chart.

line_chart(**kwargs)

Input variables

Name Description Type
plot_setup

Settings of chart (Dictionary with the following keys):

  • name: Path + name of the figure
  • width: Figure width in SI units
  • height: Figure height in SI units
  • extension: File extension
  • dots_per_inch: Resolution in dots per inch
  • marker: List of markers. See gallery
  • marker_size: List of marker sizes
  • line_width: List of line widths
  • line_style: List of line styles. See gallery
  • x_axis_label: x axis label
  • x_axis_size: x axis size
  • y_axis_label: y axis label
  • y_axis_size: y axis size
  • axises_color: Axes color
  • labels_size: Labels size
  • labels_color: Labels color
  • chart_color: Chart color
  • x_limit: x axis limits
  • y_limit: y axis limits
  • on_grid: Grid on or off
  • y_log: y log scale
  • x_log: x log scale
  • legend: List of legends
  • legend_location: Legend location
  • size_legend: Legend size
Dictionary
dataset

Dataset to plot

List or array

Output variables

Name Description Type
None The function displays the plot on the screen and saves it to the local folder of the .ipynb or .py None

Example 1

We use the line_chart function to plot a series of banana prices.

# Data
df =  {
        'x0': [2012, 2013, 2014, 2015, 2016],
        'y0': [2.50, 3.00, 2.20, 4.50, 3.50]
      }

# Chart setup
chart_config = {
                'name': 'figure_021_line_chart',
                'width': 16.0, 
                'height': 8.0,
                'extension': 'svg',
                'dots_per_inch': 600, 
                'marker': [None],
                'marker_size': [20],
                'line_width': [4],
                'line_style': ['-'],
                'x_axis_label': 'year',
                'x_axis_size': 10,
                'y_axis_label': 'price ($)',
                'y_axis_size': 10,
                'axises_color': 'red',
                'labels_size': 14,
                'labels_color': 'blue',
                'chart_color': ['#000000'],
                'on_grid': True,
                'legend': ['banana'], # or without legend 'legend': [none]
                'legend_location': 'upper left',
                'x_limit': [2012, 2016],
                'y_limit': [2, 5.00],
                'size_legend': 12,
                'y_log': False,
                'x_log': False,
            }

# Call function
line_chart(dataset=df, plot_setup=chart_config)

Figure 1. Line chart

Example 2

We use the line_chart function to plot a series of fruit prices.

# Data statement 
df =  {
        'x0': [2012, 2013, 2014, 2015, 2016],
        'y0': [2.5, 3.0, 2.2, 4.5, 3.5],
        'x1': [2012, 2016],
        'y1': [2.2, 3.2],
        'x2': [2012, 2013, 2014, 2015, 2016],
        'y2': [2.6, 2.9, 2.3, 4.2, 3.6]
       }

# Chart setup
chart_config = {
                'name': 'figure_022_line_chart',
                'width': 16.0, 
                'height': 8.0,
                'extension': 'svg',
                'dots_per_inch': 600, 
                'marker': [None, None, None],
                'marker_size': [3, 3, 3],
                'line_width': [3, 3, 3],
                'line_style': ['--', '-', 'dotted'],
                'x_axis_label': 'Year',
                'x_axis_size': 10,
                'y_axis_label': 'Price ($)',
                'y_axis_size': 10,
                'axises_color': '#000000',
                'labels_size': 14,
                'labels_color': '#000000',
                'chart_color': ['#000000','olive','r'],
                'on_grid': True,
                'legend': ['Banana', 'Apple', 'Orange'],
                'legend_location': 'upper left',
                'size_legend': 8,
                'x_limit': None,
                'y_limit': None,
                'y_log': False,
                'x_log': False,
               }

# Call function
line_chart(dataset=df, plot_setup=chart_config)

Figure 2. Line chart