Exemplo n.º 1
0
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""
Demonstrates rendering a canvas to an image at higher resolution than the
original display.
"""

import sys
import vispy.plot as vp

# Create a canvas showing plot data
canvas = vp.plot([1, 6, 2, 4, 3, 8, 5, 7, 6, 3])

# Render the canvas scene to a numpy array image with higher resolution 
# than the original canvas
scale = 4
image = canvas.render(size=(canvas.size[0]*scale, canvas.size[1]*scale))

# Display the data in the array, sub-sampled down to the original canvas
# resolution
image = image[::scale, ::scale]
canvas2 = vp.image(image)

# By default, the view adds some padding when setting its range.
# We'll remove that padding so the image looks exactly like the original
# canvas:
canvas2.view.camera.set_range(margin=0)

if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()
Exemplo n.º 2
0
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""
Demonstrates rendering a canvas to an image at higher resolution than the
original display.
"""

import sys
import vispy.plot as vp

# Create a canvas showing plot data
canvas = vp.plot([1, 6, 2, 4, 3, 8, 5, 7, 6, 3])

# Render the canvas scene to a numpy array image with higher resolution
# than the original canvas
scale = 4
image = canvas.render(size=(canvas.size[0] * scale, canvas.size[1] * scale))

# Display the data in the array, sub-sampled down to the original canvas
# resolution
image = image[::scale, ::scale]
canvas2 = vp.image(image)

# By default, the view adds some padding when setting its range.
# We'll remove that padding so the image looks exactly like the original
# canvas:
canvas2.view.camera.auto_zoom(canvas2.image, padding=0)

if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.

import numpy as np
import vispy.plot as vplt

plot_data = [1, 6, 2, 4, 3, 8, 4, 6, 5, 2]
canvas1 = vplt.plot(plot_data)

image_data = np.random.normal(size=(20, 20), loc=128, scale=60)
canvas2 = vplt.image(image_data.astype(np.ubyte))


# Start up the event loop if this is not an interactive prompt.
import sys
if sys.flags.interactive == 0:
    canvas1.app.run()
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
"""
Example of simple image plotting.
"""

import sys
import numpy as np

import vispy.plot as vp

canvas = vp.image(np.random.normal(128, 60, (20, 20)).astype(np.ubyte))

# Start up the event loop if this is not an interactive prompt.
if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()