1

I'd like to create a line chart but with 2 distinct Y axis with a different scale to replace this piece of code which generates 2 charts:

ch = chartify.Chart(blank_labels=True)
ch.set_title("Elbow method with Euclidian distance")
ch.plot.line(
    data_frame=df_elbow,
    x_column='K',
    y_column='Distortion',
    line_width=1)
ch.show()

ch = chartify.Chart(blank_labels=True)
ch.set_title("Elbow method with sum of squared errors")
ch.plot.line(
    data_frame=df_elbow,
    x_column='K',
    y_column='SSE',
    line_width=1)
ch.show()

Thanks !

Shazz
  • 13
  • 2

2 Answers2

0

Update: 2nd y-axis plots have been implemented! See chartify.examples.chart_second_axis()

Old answer: At the moment there isn't support for 2nd y-axis plots, but I'll add in an issue for it. Thanks for the suggestion!

For now I'd suggest falling back on Bokeh. See an example here.

chalpert
  • 252
  • 1
  • 8
0

Thanks, here is what I did using the Bokeh figure while waiting for chartify to support 2 axis:

import bokeh.plotting
from bokeh.models import LinearAxis, Range1d

ch = chartify.Chart(blank_labels=True)
ch.set_title("Elbow method to find optimal K")
ch.set_subtitle("Euclidian distance (Blue) and sum of squared errors (Red)")

ch.figure.y_range = Range1d(5, 14)
ch.figure.line(x=df_elbow['K'], y=df_elbow['Distortion'], line_width=1, line_color="Blue")
ch.figure.extra_y_ranges = {"sum": Range1d(start=200000, end=1200000)}
ch.figure.add_layout(LinearAxis(y_range_name="sum"), 'right')
ch.figure.line(x=df_elbow['K'], y=df_elbow['SSE'], line_width=1, y_range_name='sum', line_color="Red")
ch.show()
Shazz
  • 13
  • 2