Draw a "breast curved surface" in a 3D graph (1)

"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.

This time, referring to "Practical technique of Julia language" learned from "Breast curved surface", "Breasts" in 3D space I made a sample to draw a "curved surface". 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".

2014-0708-1055.png ↑ Drag with the mouse or press the cursor key to rotate the 3D graph. You can zoom in / out by turning the mouse wheel.

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


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

function bust(x,y)
1/8* (6*exp(-((2/3*abs(x) - 1)^2 + (2/3 *y)^2) - 1/3*(2/3*y + 1/2)^3)+ 2/3 *exp(-2.818^11*((abs(2/3*x) - 1)^2+ (2/3 *y)^2)^2) + 2/3*y - (2/3*x)^4)
end

nx = 100
ny = 51
x = linspace(-3, 3, nx)
y = linspace(-3, 3, ny)
z = zeros(Float64, length(y), length(x))

for iy = 1:length(y)
    for ix = 1:length(x)
        z[iy, ix] = bust(x[ix], y[iy])
    end
end

using PyCall
@pyimport Oppai
Oppai.graph_run(x, y, z, 10)

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


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

from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import pyqtgraph as pg
import numpy as np

def graph_run(plot_data_x, plot_data_y, plot_data_z, distance):

    app = QtGui.QApplication([])

    w = gl.GLViewWidget()
    w.resize(600,400)
    w.opts['distance'] = distance
    w.show()
    w.setWindowTitle(u'Julia+PyQtGraph sample')

    x = plot_data_x
    y = plot_data_y
    for i in range(len(y)):
        yi = [y[i]]*len(x)
        z = plot_data_z[i,:]
        pts = np.vstack([x,yi,z]).transpose()
        plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,len(y)*1.3)), width=(i+1)/10., antialias=True)
        w.addItem(plt)

    app.exec_()

Recommended Posts

Draw a "breast curved surface" in a 3D graph (1)
Draw a "breast curved surface" in a 3D graph (2)
Draw a graph of a quadratic function in Python
Draw a graph with Japanese labels in Jupyter
How to draw a 3D graph before optimization
Draw graph in python
Draw multiple photos in a graph from multiple folders
Draw a graph in Julia ... I tried a little analysis
Until drawing a 3D graph in Python on windows10
Draw a graph with NetworkX
Draw a heart in Python
Draw a graph with networkx
Draw a graph with Julia + PyQtGraph (2)
Draw a scatterplot matrix in python
Draw a loose graph with matplotlib
Draw a graph with Julia + PyQtGraph (1)
Draw a graph with Julia + PyQtGraph (3)
Draw retention rate graph in Matplotlib
Draw a graph with pandas + XlsxWriter
Draw a CNN diagram in Python
Draw a graph with PySimple GUI
How to draw a graph using Matplotlib
(Matplotlib) I want to draw a graph with a size specified in pixels
Draw a heart in Ruby with PyCall
Draw a heart in Python Part 2 (SymPy)
Solve ABC165 A, B, D in Python
Draw a tree in Python 3 using graphviz
Simply draw a graph by specifying a file
Draw a graph with PyQtGraph Part 1-Drawing
How to draw a 2-axis graph with pyplot
Create a standard normal distribution graph in Python
Draw a graph with PyQtGraph Part 3-PlotWidget settings
Draw a graph by processing with Pandas groupby
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with PyQtGraph Part 4-PlotItem settings
Draw a graph with matplotlib from a csv file
Draw a graph with PyQtGraph Part 6-Displaying a legend
[Python] How to draw a histogram in Matplotlib
Draw a weakness graph in Python and save it in various formats (Raspberry Pi, macOS)
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
[Python] How to draw a line graph with Matplotlib
Draw a graph with PyQtGraph Part 2--Detailed plot settings
I want to see the graph in 3D! I can make such a dream come true.