 |
Showing H2D, P1D and 2D function using HPlot2D
Source code name: "canvas2D_contour2.py"
Programming language: Python
Topic: Plots/Contour
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/canvas2D_contour2_1626.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from jhplot import *
from java.util import *
h1=H2D("2 Gaussians",30,-3.0, 3.0, 30, -3.0, 3.0)
p1=P1D("Data");
f1=F2D("x^2+y^2",-2,2,-2,2);
r=Random()
for i in range(1000):
h1.fill(0.6*r.nextGaussian()-0.5,r.nextGaussian());
h1.fill(0.4*r.nextGaussian()+1,0.8*r.nextGaussian()+0.5);
p1.add(100*r.nextGaussian(),100*r.nextGaussian())
c1=HPlot2D("Canvas",600,700,2,2)
c1.visible()
c1.cd(1,1)
c1.setName("2D function");
c1.setStyle(2)
c1.draw(f1)
c1.cd(2,1)
c1.setName("2D function range")
c1.setStyle(2)
c1.setRange(0,0.0,1.0,50)
c1.setRange(1,0.0,1.0,50)
c1.setRange(2,0.0,5.0,30)
c1.draw(f1)
c1.cd(1,2)
c1.setName("2D array")
c1.setStyle(2)
c1.draw(p1)
c1.cd(2,2)
c1.setName("2D histogram")
c1.setStyle(1)
c1.draw(h1)
You see the box below because you did not login.