Example #1
0
def _create_plot_component():

    # Create theta data
    numpoints = 5000
    low = 0
    high = 2*pi
    theta = arange(low, high, (high-low) / numpoints)

    # Create the radius data
    radius = cos(3*theta)

    # Create a new polar plot with radius and theta data
    plot = create_polar_plot((radius,theta),color=(0.0,0.0,1.0,1), width=4.0)

    return plot
    def _create_window(self):
        # Create theta data
        numpoints = 5000
        low = 0
        high = 2*pi
        theta = arange(low, high, (high-low) / numpoints)

        # Create the radius data
        radius = cos(3*theta)

        # Create a new polar plot with radius and theta data
        plot = create_polar_plot((radius,theta),color=(0.0,0.0,1.0,1), width=4.0)

        label = DataLabel(component=plot, data_point=(radius[100],theta[200]),
                          padding=40,
                          label_format = 'What shall I write here?',
                          bgcolor = "transparent",
                          border_visible=False)
        plot.overlays.append(label)        

        return Window(self, -1, component=plot)
from numpy import arange, pi, sin, cos
from enthought.enable.example_support import DemoFrame, demo_main
from enthought.enable.api import Window
from enthought.traits.api import false
from enthought.chaco.api import create_polar_plot

numpoints = 5000
low = 0
high = 2*pi
theta = arange(low, high, (high-low) / numpoints)

# Create the radius data
radius = cos(3*theta)

# Create a new polar plot with radius and theta data
myplot = create_polar_plot((radius,theta),color=(0.0,0.0,1.0,1), width=4.0)

# We now need to set the plot's size, and add a little padding for the axes.
# (Normally, when Chaco plots are placed inside WX windows, the bounds are
# set automatically by the window.)
myplot.padding = 50
myplot.bounds = [400,400]
myplot.outer_bounds = [600,600]

def main():
    # Now we create a canvas of the appropriate size and ask it to render
    # our component.  (If we wanted to display this plot in a window, we
    # would not need to create the graphics context ourselves; it would be
    # created for us by the window.)
    plot_gc = chaco.PlotGraphicsContext(myplot.outer_bounds)
    plot_gc.render_component(myplot)
 def _create_polar_plot(self, plotitem, values, **kwargs):
     plot = create_polar_plot(values, **kwargs)
     return plot