Exemplo n.º 1
0
def init_plot_chart(scrolled_window: Gtk.ScrolledWindow, figure: Figure,
                    canvas: FigureCanvas, axis: Axes) -> Any:
    axis.grid(True, linestyle=':')
    axis.margins(x=0, y=0.05)

    temp_label = Gtk.Label()
    scrolled_window.add(temp_label)
    text_color = rgba_to_hex(temp_label.get_style_context().get_color(
        Gtk.StateType.NORMAL))
    text_color_alpha = text_color[:-2] + '80'
    scrolled_window.remove(temp_label)
    axis.set_facecolor('#00000000')
    axis.set_xlabel('Temperature [°C]', color=text_color)
    axis.set_ylabel('Duty [%]', color=text_color)
    axis.tick_params(colors=text_color, grid_color=text_color_alpha)
    for spine in axis.spines.values():
        spine.set_edgecolor(text_color_alpha)
    figure.subplots_adjust(top=1)
    canvas.set_size_request(400, 300)
    scrolled_window.add_with_viewport(canvas)
    # Returns a tuple of line objects, thus the comma
    lines = axis.plot([], [],
                      'o-',
                      linewidth=3.0,
                      markersize=10,
                      antialiased=True,
                      color=GRAPH_COLOR_HEX)
    axis.set_ybound(lower=-5, upper=105)
    axis.set_xbound(MIN_TEMP, MAX_TEMP)
    figure.canvas.draw()
    return lines
Exemplo n.º 2
0
Arquivo: view.py Projeto: Raiu/gkraken
def init_plot_chart(scrolled_window: Gtk.ScrolledWindow,
                    figure: Figure,
                    canvas: FigureCanvas,
                    axis: Axes) -> Any:
    axis.grid(True, linestyle=':')
    axis.margins(x=0, y=0.05)
    axis.set_facecolor('#00000000')
    axis.set_xlabel('Liquid temperature [°C]')
    axis.set_ylabel('Duty [%]')
    figure.subplots_adjust(top=1)
    canvas.set_size_request(400, 300)
    scrolled_window.add_with_viewport(canvas)
    # Returns a tuple of line objects, thus the comma
    lines = axis.plot([], [], 'o-', linewidth=3.0, markersize=10, antialiased=True)
    axis.set_ybound(lower=0, upper=105)
    axis.set_xbound(MIN_TEMP, MAX_TEMP)
    figure.canvas.draw()
    return lines
Exemplo n.º 3
0
def init_plot_chart(scrolled_window: Gtk.ScrolledWindow, figure: Figure,
                    canvas: FigureCanvas, axis: Axes) -> Any:
    # 3.4.1 display workaround:
    axis.patch.set_visible(False)
    temp_window = Gtk.Window()
    style = temp_window.get_style_context()
    bg_colour = style.get_background_color(
        Gtk.StateType.NORMAL).to_color().to_floats()
    color_converter = ColorConverter()
    color_converter.to_rgba(bg_colour)
    figure.patch.set_facecolor(bg_colour)

    # correct text and line colors
    temp_label = Gtk.Label()
    scrolled_window.add(temp_label)
    text_color = rgba_to_hex(temp_label.get_style_context().get_color(
        Gtk.StateType.NORMAL))
    text_color_alpha = text_color[:-2] + '80'
    scrolled_window.remove(temp_label)

    axis.grid(True, linestyle=':')
    axis.margins(x=0, y=0.05)
    axis.set_xlabel('Liquid temperature [°C]', color=text_color)
    axis.set_ylabel('Duty [%]', color=text_color)
    axis.tick_params(colors=text_color, grid_color=text_color_alpha)
    for spine in axis.spines.values():
        spine.set_edgecolor(text_color_alpha)
    figure.subplots_adjust(top=1)
    canvas.set_size_request(400, 300)
    scrolled_window.add_with_viewport(canvas)
    # Returns a tuple of line objects, thus the comma
    lines = axis.plot([], [],
                      'o-',
                      linewidth=3.0,
                      markersize=10,
                      antialiased=True)
    axis.set_ybound(lower=0, upper=105)
    axis.set_xbound(MIN_TEMP, MAX_TEMP)
    figure.canvas.draw()
    return lines