1

我想创建一个折线图,但有 2 个不同的 Y 轴和不同的比例来替换生成 2 个图表的这段代码:

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()

谢谢 !

4

2 回答 2

0

谢谢,这是我在等待 chartify 支持 2 轴时使用散景图所做的:

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()
于 2018-11-22T01:29:15.243 回答
0

更新:第二个 y 轴图已经实现!看chartify.examples.chart_second_axis()

旧答案:目前不支持第二个 y 轴图,但我会为此添加一个问题。感谢您的建议!

现在我建议回到 Bokeh。请参阅此处的示例

于 2018-11-21T19:23:21.760 回答