Article style (BG) with an insert plot
Source code name: "style9.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1. Last modified: 07/25/2017. License: Pro
https://datamelt.org/code/cache/style9_3767.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.



import os,sys
from java.awt import *
from java.util import Random
from jhplot import * 

def applyStyleGray(c1,f1,h1,p1):

     style="Article style (BG) with an insert plot"
     st = Font.BOLD + Font.ITALIC;
     f = Font("Serif",st,14);

     c1.setAntiAlias(True) 
     c1.setGTitle(style,f)    
     c1.setNameX("X values",Font("Serif", Font.ITALIC, 20))
     c1.setNameY("Y values",Font("Serif", Font.ITALIC, 20))
     

     f1.setColor(Color.black)
     f1.setPenWidth(3)

     # apply style for histogram
     h1.setFill(1)
     h1.setPenWidth(2)
     h1.setErrX(0)
     h1.setErrY(1)
     h1.setFillColor( Color(0x787C80)  )

     # apply style for data points 
     p1.setSymbol(4)
     p1.setSymbolSize(6)
     p1.setColor( Color.black ) 

     return style 


# make empty canvas in some range
c1 =HPlotJa("Canvas",600,500,2,1)
c1.setAntiAlias(False)
c1.visible()
c1.setRange(0,100,0,150)
c1.setMarginLeft(0.13)

h1 = H1D("Histogram",20, 50.0, 100.0)
f1=F1D("cos(x)*x",1,50)
f1.setPoints(5000) 
p1= P1D("X-Y data")

rand = Random(10)
for i in range(500):
      h1.fill(85+10*rand.nextGaussian())
      if (i<200): p1.add(56+7*rand.nextGaussian(),70+7*rand.nextGaussian())
        


style=applyStyleGray(c1,f1,h1,p1)


## now put a few points
c1.cd(1,1)
c1.setShowStatBox(0)

# change pad positions and sizes
c1.setPad(1,1,0.1, 0.1, 0.8,0.8)
c1.setPad(2,1,0.5, 0.14, 0.3,0.3)
c1.draw(f1)
c1.draw(h1)


c1.cd(2,1) # new pad with different location
c1.setRange(0,100,0,100)
st = Font.BOLD + Font.ITALIC;
f = Font("Serif",st,22);
f = Font("Serif",st,22); 
c1.setNameX("X_{γ}",Font("Serif", Font.ITALIC, 20))
c1.setNameY("Y_{β}",Font("Serif", Font.ITALIC, 20))     

# c1.setLabel(0,0.835,0.5,"X")
# c1.setLabel(1,0.435,0.13,"Y")

c1.setShowStatBox(0)
c1.draw(p1)


# now show all objects
c1.update()

# import sys
# expfile=sys.argv[0].replace(".py",".png")
# c1.export(expfile)



You see the box below because you did not login.