예제 #1
0
파일: add_tool.py 프로젝트: skailasa/chaco
from chaco.default_colormaps import jet

# Crate some scalar data
xs = linspace(0, 10, 200)
ys = linspace(0, 20, 400)
x, y = meshgrid(xs, ys)
z = sin(x) * y

# Create a pseudo-color-map
pcolor(x, y, z, name='sin_x_times_y')

# Change the color mapping
colormap(jet)

# Add some titles
title("pseudo colormap image plot")

# From the current plot object, grab the first plot
img_plot = curplot().plots['sin_x_times_y'][0]

# Add a custom tool - in this case, an ImageInspector
from chaco.tools.api import ImageInspectorTool, ImageInspectorOverlay

tool = ImageInspectorTool(img_plot)
img_plot.tools.append(tool)
overlay = ImageInspectorOverlay(img_plot,
                                image_inspector=tool,
                                bgcolor="white",
                                border_visible=True)
img_plot.overlays.append(overlay)
예제 #2
0
"""This example shows how to createa log-log plot using the chaco
`shell` subpackage."""

# Major library imports
from numpy import linspace, exp

# Enthought library imports
from chaco.shell import show, title, loglog, hold

# Create some data
x = linspace(1, 15, 200)

# Create some line plots
loglog(x, x**2, "b-.", name="y=x**2", bgcolor="white")
hold(True)
loglog(x, x**4 + 3 * x + 2, "r-", name="y=x**4+3x+2", bgcolor="white")
loglog(x, exp(x), "g-", name="y=exp(x)", bgcolor="white")
loglog(x, x, "m--", name="y=x", bgcolor="white")

# Add some titles
title("simple loglog plots")

#This command is only necessary if running from command line
show()
예제 #3
0
# Major library imports
from numpy import linspace, pi, sin

# Enthought library imports
from chaco.shell import show, plot, title, curplot
from chaco.scales.api import CalendarScaleSystem

# Create some data
numpoints = 100
x = linspace(-2 * pi, 2 * pi, numpoints)
y1 = sin(x)

# Create the dates
import time
now = time.time()
dt = 24 * 3600  # data points are spaced by 1 day
dates = linspace(now, now + numpoints * dt, numpoints)

# Create some line plots
plot(dates, y1, "b-", bgcolor="white")

# Add some titles
title("Plotting Dates")

# Set the plot's horizontal axis to be a time scale
curplot().x_axis.tick_generator.scale = CalendarScaleSystem()

#This command is only necessary if running from command line
show()
예제 #4
0
"""
This example demonstrates creating a contour plot using the chaco
shell subpackage.
"""

# Major library imports
from numpy import linspace, meshgrid, sin
from scipy.special import jn

# Enthought library imports
from chaco.shell import show, title, contour


# Crate some scalar data
xs = linspace(-10,10,200)
ys = linspace(-10,10,400)
x,y = meshgrid(xs,ys)
z = sin(x)*x*jn(0,y)

# Create a contour line plot
contour(x,y,z, bgcolor="black")

# Add some titles
title("contour line plot")

# This command is only necessary if running from command line
show()
예제 #5
0
파일: lines.py 프로젝트: 5n1p/chaco
"""This example displays some line plots in different colors and styles using
the chaco.shell subpackage.

The functions in the chaco.shell package allow us to quickly generate plots
with some basic interactivity without using the object-oriented core of Chaco.
"""

from numpy import linspace, pi, sin, cos
from chaco.shell import plot, hold, title, show

# Create some data
x = linspace(-2*pi, 2*pi, 100)
y1 = sin(x)
y2 = cos(x)

# Create some line plots using the plot() command and using
# Matlab-style format specifiers
plot(x, y1, "b-", bgcolor="white")
hold()
plot(x, y2, "g-.", marker_size=2)

# Set the plot title
title("simple line plots")

# If running this from the command line and outside of a wxPython
# application or process, the show() command is necessary to keep
# the plot from disappearing instantly.  If a wxPython mainloop
# is already running, then this command is not necessary.
show()
예제 #6
0
"""
This example displays some line plots in different colors and styles using
the chaco.shell subpackage.

The functions in the chaco.shell package allow us to quickly generate plots
with some basic interactivity without using the object-oriented core of Chaco.
"""

from numpy import linspace, pi, sin, cos
from chaco.shell import plot, hold, title, show

# Create some data
x = linspace(-2 * pi, 2 * pi, 100)
y1 = sin(x)
y2 = cos(x)

# Create some line plots using the plot() command and using
# Matlab-style format specifiers
plot(x, y1, "b-", bgcolor="white")
hold()
plot(x, y2, "g-.", marker_size=2)

# Set the plot title
title("simple line plots")

# If running this from the command line and outside of a wxPython
# application or process, the show() command is necessary to keep
# the plot from disappearing instantly.  If a wxPython mainloop
# is already running, then this command is not necessary.
show()
예제 #7
0
파일: imshow.py 프로젝트: enthought/chaco
import sys

# Enthought library imports
from traits.util.resource import find_resource
from chaco.shell import imread, imshow, title, show

# Get the image file using the find_resource module
image_path = os.path.join('examples','basic','capitol.jpg')
alt_path = os.path.join('..','basic','capitol.jpg')
image_file = find_resource('Chaco', image_path, alt_path=alt_path)

# Check to see if the image was found
if image_file is None:
    print('The image "capitol.jpg" could not be found.')
    sys.exit()

# Create the image
image = imread(image_file)

# Create the plot
imshow(image, origin="top left")

# Alternatively, you can call imshow using the path to the image file
#imshow(alt_path)

# Add a title
title("Simple Image Plot")

# This command is only necessary if running from command line
show()
예제 #8
0
# Mayor Library Imports
from numpy import linspace, meshgrid, tanh

# Enthought Library Imports
from chaco.shell import contourf, colormap, title, show
from chaco.default_colormaps import jet


# Crate some scalar data
xs = linspace(-10, 10, 200)
ys = linspace(-10, 10, 400)
x, y = meshgrid(xs, ys)
z = x * tanh(y)

# Create a filled contour plot
contourf(x, y, z)
colormap(jet)

# Add some titles
title("filled contour plot")

# This command is only necessary if running from command line
show()
예제 #9
0
# Mayor Library imports
from numpy import linspace, meshgrid, sin
from scipy.special import jn

# Enthought library imports
from chaco.shell import show, title, contour


# Crate some scalar data
xs = linspace(-10,10,200)
ys = linspace(-10,10,400)
x,y = meshgrid(xs,ys)
z = sin(x)*x*jn(0,y)

# Create a contour line plot
contour(x,y,z, bgcolor="black")

# Add some titles
title("contour line plot")

#This command is only necessary if running from command line
show()
예제 #10
0
"""
This example shows how to create a semi-log plot using the `shell` package.
"""

# Major library imports
from numpy import linspace, exp

# Enthought library imports
from chaco.shell import semilogy, hold, title, show


# Create some data
x = linspace(1, 10, 200)

# Create some line plots
semilogy(x, exp(x), "b-", name="y=exp(x)", bgcolor="white")
hold(True)
semilogy(x, x**x, "r--", name="y=x**x")
semilogy(x, x, "g-", name="y=x")

# Add some titles
title("simple semilog plots")

# This command is only necessary if running from command line
show()

예제 #11
0
 def test_script(self):
     x = linspace(-2*pi, 2*pi, 100)
     y = sin(x)
     plot(x, y, "r-")
     title("First plot")
     ytitle("sin(x)")
예제 #12
0
파일: loglog.py 프로젝트: 5n1p/chaco
"""This example shows how to createa log-log plot using the chaco
`shell` subpackage."""

# Major library imports
from numpy import linspace, exp

# Enthought library imports
from chaco.shell import show, title, loglog, hold


# Create some data
x = linspace(1, 15, 200)

# Create some line plots
loglog(x, x**2, "b-.", name="y=x**2", bgcolor="white")
hold(True)
loglog(x, x**4+3*x+2, "r-", name="y=x**4+3x+2", bgcolor="white")
loglog(x, exp(x), "g-", name="y=exp(x)", bgcolor="white")
loglog(x, x, "m--", name="y=x", bgcolor="white")

# Add some titles
title("simple loglog plots")

#This command is only necessary if running from command line
show()
예제 #13
0
파일: dates.py 프로젝트: 5n1p/chaco
# Major library imports
from numpy import linspace, pi, sin

# Enthought library imports
from chaco.shell import show, plot, title, curplot
from chaco.scales.api import CalendarScaleSystem

# Create some data
numpoints = 100
x = linspace(-2*pi, 2*pi, numpoints)
y1 = sin(x)

# Create the dates
import time
now = time.time()
dt = 24 * 3600    # data points are spaced by 1 day
dates = linspace(now, now + numpoints*dt, numpoints)

# Create some line plots
plot(dates, y1, "b-", bgcolor="white")

# Add some titles
title("Plotting Dates")

# Set the plot's horizontal axis to be a time scale
curplot().x_axis.tick_generator.scale = CalendarScaleSystem()

#This command is only necessary if running from command line
show()

예제 #14
0
# Enthought library imports
from chaco.shell import show, title, plot, pcolor, colormap, curplot
from chaco.default_colormaps import jet

# Crate some scalar data
xs = linspace(0,10,200)
ys = linspace(0,20,400)
x,y = meshgrid(xs,ys)
z = sin(x)*y

# Create a pseudo-color-map
pcolor(x,y,z)

#change the color mapping
colormap(jet)

# Add some titles
title("pseudo colormap image plot")

# Add a custom tool - in this case, an ImageInspector
from chaco.tools.api import ImageInspectorTool, ImageInspectorOverlay
img_plot = curplot().plots.values()[0][0]
tool = ImageInspectorTool(img_plot)
img_plot.tools.append(tool)
overlay = ImageInspectorOverlay(img_plot, image_inspector=tool,
                                bgcolor="white", border_visible=True)
img_plot.overlays.append(overlay)

#This command is only necessary if running from command line
show()
예제 #15
0
import sys

# Enthought library imports
from traits.util.resource import find_resource
from chaco.shell import imread, imshow, title, show

# Get the image file using the find_resource module
image_path = os.path.join('examples', 'basic', 'capitol.jpg')
alt_path = os.path.join('..', 'basic', 'capitol.jpg')
image_file = find_resource('Chaco', image_path, alt_path=alt_path)

# Check to see if the image was found
if image_file is None:
    print('The image "capitol.jpg" could not be found.')
    sys.exit()

# Create the image
image = imread(image_file)

# Create the plot
imshow(image, origin="top left")

# Alternatively, you can call imshow using the path to the image file
#imshow(alt_path)

# Add a title
title("Simple Image Plot")

# This command is only necessary if running from command line
show()
"""This example demonstrates creating a filled contour plot using the chaco
shell subpackage.
"""

# Major library Imports
from numpy import linspace, meshgrid, tanh

# Enthought Library Imports
from chaco.shell import contourf, colormap, title, show
from chaco.default_colormaps import jet

# Crate some scalar data
xs = linspace(-10, 10, 200)
ys = linspace(-10, 10, 400)
x, y = meshgrid(xs, ys)
z = x * tanh(y)

# Create a filled contour plot
contourf(x, y, z)
colormap(jet)

# Add some titles
title("filled contour plot")

#This command is only necessary if running from command line
show()
예제 #17
0
 def test_script(self):
     x = linspace(-2*pi, 2*pi, 100)
     y = sin(x)
     plot(x, y, "r-")
     title("First plot")
     ytitle("sin(x)")
예제 #18
0
"""This example shows how to create a scatter plot using the `shell` package.
"""

# Major library imports
from numpy import linspace, random, pi

# Enthought library imports
from chaco.shell import plot, hold, title, show


# Create some data
x = linspace(-2*pi, 2*pi, 100)
y1 = random.random(100)
y2 = random.random(100)

# Create some scatter plots
plot(x, y1, "b.")
hold(True)
plot(x, y2, "g+", marker_size=2)

# Add some titles
title("simple scatter plots")

# This command is only necessary if running from command line
show()
예제 #19
0
# Mayor Library imports
from numpy import linspace, exp

# Enthought library imports
from chaco.shell import semilogy, hold, title, show


# Create some data
x = linspace(1, 10, 200)

# Create some line plots
semilogy(x, exp(x), "b-", name="y=exp(x)", bgcolor="white")
hold(True)
semilogy(x, x**x, "r--", name="y=x**x")
semilogy(x, x, "g-", name="y=x")

# Add some titles
title("simple semilog plots")

#This command is only necessary if running from command line
show()