 |
Four charts based on the HChart
Source code name: "canvas2D_chart4.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/canvas2D_chart4_4535.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 java.awt import Color
from java.awt import Font
from java.util import Random
from math import *
from jhplot import *
c1 = HChart("Canvas",600,500, 2, 2)
c1.setGTitle("Functions and points")
c1.visible()
c1.cd(1,1);
f1= F1D("x*x*cos(x)",-2,2);
f2= F1D("x*x",-2,2);
f3= F1D("x*x*sin(x)",-2,2);
f1.setPenWidth(1);
f1.setColor(Color.gray);
f1.setLineStyle(0);
c1.add(f1);
f2.setPenWidth(2);
f2.setColor(Color.black);
f2.setLineStyle(1);
c1.add(f2);
f3.setPenWidth(3);
f3.setColor(Color.green);
f3.setLineStyle(3);
c1.add(f3);
c1.update();
c1.cd(2,1);
p1 =P1D("set 1");
p1.add(10,20);
p1.add(16,18);
p1.setSymbol(5);
p1.setSymbolSize(6);
c1.add(p1);
p2 = P1D("set 2");
p2.add(10,23);
p2.add(14,23);
c1.add(p2);
c1.cd(1,2);
p3 = P1D("XY errors");
p3.setColor(Color.blue);
p3.add(10,20,5);
p3.add(16,18,5);
c1.add(p3);
p4 = P1D("XY errors");
p4.setColor(Color.red);
p4.add(8,10,3,3,2,1);
p4.add(14,23,5,5,2,3);
p4.setSymbol(3);
p4.setSymbolSize(6);
c1.add(p4);
c1.update();
c1.cd(2,2);
h1 = H1D("Test 1",20, -1.0, 1.0);
h2 = H1D("Test 2",20, -2.0, 1.0);
rand =Random();
for i in range(200):
x=rand.nextGaussian();
h1.fill(x);
h2.fill(rand.nextGaussian()*0.2);
h1.setFillColor(Color.blue);
c1.add(h1);
h2.setFillColor(Color.red);
c1.add(h2);
c1.update();
# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png")
You see the box below because you did not login.