[PYTHON] Draw a "breast curved surface" in a 3D graph (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.

This time, we will conduct an experiment to enlarge "boobs" by referring to "Length calculation by boobs curved surface equation". I tried to. The calculation result obtained by Julia is displayed as a graph by Matplotlib. (Please create an environment and move it)

Note: For the environment construction, refer to "Drawing a graph in the programming language Julia". Added steps 4, 6 and 11 on 2014/07/04. ** If you have built the environment by looking at the above article before 2014/07/04, please perform additional steps 4, 6 and 11. **Thank you.

↓ Example of $ ALPHA = 1 $. "Breasts" are small. Drag the left button to rotate the 3D graph. You can zoom in / out by dragging the right button. alpha-1-beta-1.gif

↓ Example of $ ALPHA = 3 $. "Breasts" are big. Drag the left button to rotate the 3D graph. You can zoom in / out by dragging the right button. alpha-3-beta-1.gif

Oppai2.jl


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

using PyPlot

using PyCall
@pyimport matplotlib.cm as cm
@pyimport matplotlib.font_manager as fm
@pyimport matplotlib.pyplot as plt
@pyimport numpy as np

ALPHA = 1.0
BETA  = 1.0
GAMMA = 1.0 / ALPHA

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

fig = plt.figure()
ax = fig[:gca](projection="3d")

nx = 201
ny = 201
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

x, y = np.meshgrid(x, y)
sf = ax[:plot_surface](x,y,z,rstride=4,cstride=4,cmap=cm.coolwarm,linewidth=0.1,antialiased=true)
fig[:colorbar](sf,shrink=0.5,aspect=5)

ax[:set_zlim](-4,3)
ax[:view_init](0,-90)

@windows? (
begin
    #fp = fm.FontProperties(fname="C:\\WINDOWS\\Fonts\\msgothic.ttc")
    fp = fm.FontProperties(fname="C:\\WINDOWS\\Fonts\\msmincho.ttc")
    plt.title("Julia+Matplotlib sample", fontproperties=fp, fontsize=25)
end
: begin
    plt.title("Julia+Matplotlib sample", fontsize=25)
end
)

plt.savefig("Oppai2")
plt.show(block=true)

Recommended Posts

Draw a "breast curved surface" in a 3D graph (1)
Draw a "breast curved surface" in a 3D graph (2)
Draw a flat surface with a matplotlib 3d graph
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 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
Draw a heart in Ruby with PyCall
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
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with PyQtGraph Part 4-PlotItem settings
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.