pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
Wiki

MatplotlibPygame

      
Search:  
 
 

Using matplotlib (matplotlib is a python 2D plotting library) with pygame.

import matplotlib
matplotlib.use("Agg")
 
import matplotlib.backends.backend_agg as agg
 
 
import pylab
 
fig = pylab.figure(figsize=[4, 4], # Inches
                   dpi=100,        # 100 dots per inch, so the resulting buffer is 400x400 pixels
                   )
ax = fig.gca()
ax.plot([1, 2, 4])
 
canvas = agg.FigureCanvasAgg(fig)
canvas.draw()
renderer = canvas.get_renderer()
raw_data = renderer.tostring_rgb()
 
import pygame
from pygame.locals import *
 
pygame.init()
 
window = pygame.display.set_mode((600, 400), DOUBLEBUF)
screen = pygame.display.get_surface()
 
size = canvas.get_width_height()
 
surf = pygame.image.fromstring(raw_data, size, "RGB")
screen.blit(surf, (0,0))
pygame.display.flip()
 
while True:
    pass
spotlight

 
our projects
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
 
recent releases
Jun 24, 2015

Jun 23, 2015

Jun 21, 2015

Jun 17, 2015

Jun 14, 2015

Jun 8, 2015

Jun 7, 2015

May 31, 2015

May 28, 2015

May 18, 2015

May 7, 2015


... more!
 
for pygame related questions, comments, and suggestions, please see help (lists, irc)