コード例 #1
0
ファイル: log_plot.py プロジェクト: brycehendrix/chaco
def _create_plot_component():

    # Create some x-y data series to plot
    x = linspace(1.0, 8.0, 200)
    pd = ArrayPlotData(index = x)
    pd.set_data("y0", sqrt(x))
    pd.set_data("y1", x)
    pd.set_data("y2", x**2)
    pd.set_data("y3", exp(x))
    pd.set_data("y4", gamma(x))
    pd.set_data("y5", x**x)

    # Create some line plots of some of the data
    plot = Plot(pd)
    plot.plot(("index", "y0"), line_width=2, name="sqrt(x)", color="purple")
    plot.plot(("index", "y1"), line_width=2, name="x", color="blue")
    plot.plot(("index", "y2"), line_width=2, name="x**2", color="green")
    plot.plot(("index", "y3"), line_width=2, name="exp(x)", color="gold")
    plot.plot(("index", "y4"), line_width=2, name="gamma(x)",color="orange")
    plot.plot(("index", "y5"), line_width=2, name="x**x", color="red")

    # Set the value axis to display on a log scale
    plot.value_scale = "log"

    # Tweak some of the plot properties
    plot.title = "Log Plot"
    plot.padding = 50
    plot.legend.visible = True

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)

    return plot
コード例 #2
0
def stairstep_plot(energy, data, data_name):
    # Munge the data into a plotable form
    x, y = stair_step(energy, data)

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)

    # Create the plot
    plot = Plot(pd)
    plot.plot(("index", "value"),
              type="line",
              marker="circle",
              index_sort="ascending",
              color="red",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = data_name
    plot.line_width = 0.5
    plot.padding = 100

    plot.x_axis.title = "Energy [MeV]"
    plot.x_axis.title_font = "Roman 16"
    plot.x_axis.tick_label_font = "Roman 12"
        
    plot.y_axis.title = "Data"
    plot.y_axis.title_font = "Roman 16"
    plot.y_axis.tick_label_font = "Roman 12"

    plot.index_scale = 'log'
    plot.value_scale = 'log'

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
   
    return plot