Data array P1D and how to show it using HPlot
Code: "points2.py". Programming language: Python
DMelt Version 1. Last modified: 12/08/2015. License: Pro
https://datamelt.org/code/cache/points2_8997.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,Font
from jhplot import *
from math import sqrt;
from java.text import DecimalFormat
# make main canvas
c1 = HPlot("Canvas",600,400,2, 2)
c1.visible(1)
c1.setAutoRange()
c1.viewHisto(0); # make sure starts from 0
c1.setGTitle("How to read external files", Color.blue) #put title
c1.setGrid(0,0)
c1.setGrid(1,0)
# WWW directory with the data files
DataDir="http://datamelt.org/examples/data/";
# show points without errors
p1= P1D("File data1.d", DataDir+"data1.d");
p1.setColor(Color.blue)
p1.setSymbolSize(4)
c1.cd(1,1)
c1.draw(p1)
# print statistics
stat=p1.getStat(0)
for key in stat:
print key , '\t', stat[key]
# make file
# p1.toFile("aaa.d")
# show points with statistical errors in y
c1.cd(1,2)
c1.setAutoRange()
c1.setGrid(0,0)
c1.setGrid(1,0)
p2= P1D("File data2.d", DataDir+"data2.d");
p2.setErr(1)
c1.draw(p2)
# show table
# HTable(p2)
# show points with statistical errors in x and y
c1.cd(2,1)
c1.setAutoRange()
c1.setGrid(0,0)
c1.setGrid(1,0)
p3= P1D("File data3.d", DataDir+"data3.d");
p3.setErr(1)
c1.draw(p3)
# show table
# HTable(p3)
# show points with statistical and systematical errors
c1.cd(2,2)
c1.setAutoRange()
c1.setGrid(0,0)
c1.setGrid(1,0)
p4= P1D("File data4.d", DataDir+"data4.d");
p4.setErr(1)
p4.setErrX(1)
p4.setErrY(1)
p4.setColor(Color.blue)
c1.draw(p4)
# show table
# HTable(p4)
# show in spreadsheet
# SPsheet(p2)
# show in a LaTeX table
# xformat=DecimalFormat("##.####E00");
# yformat=xformat;
# p4.toFileAsLatex("ok",xformat,yformat)
# export to data file
# p4.toFile("file.d")
# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png")
You see the box below because you did not login.