[PYTHON] Draw a graph with Julia + PyQtGraph (2)

"Draw a graph in the programming language Julia" I succeeded in moving the sample for the time being, but the data created by my own program (in Julia language) I decided to find out how to draw a graph using. I made a sample to display the legend / axis label and change the background color / foreground color (for printing). As usual, the calculation result obtained by Julia is displayed as a graph in PyQtGraph. (Please create an environment and move it)

Note: For the environment construction, refer to "Drawing a graph in the programming language Julia".


jl:ArrowSample2.jl(C:\julia-0.2.1-win32\Save to bin)

# -*- coding: utf-8 -*-

using PyCall

@pyimport ArrowSample2
x  = linspace(-10, 10, 2001)
y1 = [ x[i]*x[i] for i=1:length(x) ]
y2 = [ x[i]*2+50 for i=1:length(x) ]
ArrowSample2.graph_run(x, y1, y2)

python:ArrowSample2.py(C:\julia-0.2.1-win32\Save to bin)

# -*- coding: utf-8 -*-

from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg

def graph_run(plot_data_x, plot_data_y1, plot_data_y2):

    app = QtGui.QApplication([])

    #Specifying antialiasing makes the plot cleaner
    pg.setConfigOption('background', (255, 255, 255)) #Background = white
    pg.setConfigOption('foreground', (0, 0, 0))       #Foreground = black

    win = pg.GraphicsWindow(title=u'Julia+PyQtGraph sample')

    mypen=pg.mkPen(color=(255, 0, 0), style=QtCore.Qt.DotLine) #Dotted line, red

    p1 = win.addPlot(title=u'Legend, axis label, background color / foreground color')
    p1.setLabel('left', u'Y axis', units=u'Seconds')
    p1.setLabel('bottom', u'X axis', units=u'm')
    c1 = p1.plot(x=plot_data_x, y=plot_data_y1, pen=(0,0,255), name=u'Graph 1') #Solid line, blue
    c2 = p1.plot(x=plot_data_x, y=plot_data_y2, pen=mypen, name=u'Graph 2')     #Dotted line, red
    p1.showGrid(x=True, y=True) #Show grid

    #Arrow animation(Graph 1)
    a1 = pg.CurveArrow(c1)
    anim1 = a1.makeAnimation(loop=-1)

    #Arrow animation(Graph 2)
    a2 = pg.CurveArrow(c2)
    anim2 = a2.makeAnimation(loop=-1)


Recommended Posts

Draw a graph with Julia + PyQtGraph (2)
Draw a graph with Julia + PyQtGraph (1)
Draw a graph with Julia + PyQtGraph (3)
Draw a graph with PyQtGraph Part 1-Drawing
Draw a graph with NetworkX
Draw a graph with networkx
Draw a graph with PyQtGraph Part 3-PlotWidget settings
Draw a graph with PyQtGraph Part 4-PlotItem settings
Draw a graph with PyQtGraph Part 6-Displaying a legend
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
Draw a loose graph with matplotlib
Draw a graph with pandas + XlsxWriter
Draw a graph with PyQtGraph Part 2--Detailed plot settings
Draw a graph with PySimple GUI
Draw a flat surface with a matplotlib 3d graph
Draw a graph with Japanese labels in Jupyter
How to draw a 2-axis graph with pyplot
Draw a graph by processing with Pandas groupby
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with matplotlib from a csv file
Create a heatmap with pyqtgraph
Draw a graph in Julia ... I tried a little analysis
[Python] How to draw a line graph with Matplotlib
Study math with Python: Draw a sympy (scipy) graph with matplotlib
Draw a beautiful circle with numpy
Let's make a graph with python! !!
[Visualization] I want to draw a beautiful graph with Plotly
Make a nice graph with plotly
Easily draw a map with matplotlib.basemap
[PyQt] Display a multi-axis graph with QtChart
How to draw a graph using Matplotlib
Draw a heart in Ruby with PyCall
Draw a Mandelbrot set with Brainf * ck
Simply draw a graph by specifying a file
Create a graph with borders removed with matplotlib
(Matplotlib) I want to draw a graph with a size specified in pixels
How to draw a bar graph that summarizes multiple series with matplotlib
Draw a graph that can be moved around with HoloViews and Bokeh
Draw a graph of a quadratic function in Python
How to draw a 3D graph before optimization
Draw a "breast curved surface" in a 3D graph (1)
A memo that made a graph animated with plotly
Try to draw a life curve with python
[Python] Draw a Mickey Mouse with Turtle [Beginner]
Draw a "breast curved surface" in a 3D graph (2)
I made a random number graph with Numpy
Draw multiple photos in a graph from multiple folders
[Python] Draw a Qiita tag relationship diagram with NetworkX
A4 size with python-pptx
I tried to draw a route map with Python
Visualize railway line data as a graph with Cytoscape 2
Forcibly draw something like a flowchart with Python, matplotlib
Band graph with matplotlib
Create a 3D model viewer with PyQt5 and PyQtGraph
Decorate with a decorator
Draw graph in python
[Python] How to draw a scatter plot with Matplotlib
Data visualization with Python-It's too convenient to draw a graph by attribute with "Facet" at once
Create a partial correlation matrix and draw an independent graph
[pyqtgraph] Add region to the graph and link it with the graph region
Multiple file processing with Kivy + Matplotlib + Draw Graph on GUI