Skip to content

Stata module to add a graph as an inset to another graph

License

Notifications You must be signed in to change notification settings

benjann/grinset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grinset

Stata module to add a graph as an inset to another graph

grinset has been inspired by a note on inset plots by Tibbles and Melse (2023).

To install grinset from SSC, type

. ssc install grinset, replace

To install grinset from GitHub, type

. net install grinset, replace from(https://raw.githubusercontent.com/benjann/grinset/main/)

Stata 14 (or newer) is required.


Example (use of grstyle and is made; type ssc install grstyle to install the package; grstyle also requires palettes and colrspace, so additionally type ssc install palettes and ssc install colrspace).

Data and setup.

sysuse auto, clear
grstyle init
grstyle set plain, nogrid
grstyle set color sb
grstyle set color sb, select(2) inten(.7): histogram
grstyle set color sb, select(2): histogram_line

Main graph.

scatter price mpg

example 1

Add a histogram.

grinset r=5: histogram mpg, percent

example 2

Move the inset to a different position, change size, and change scaling of text and markers.

grinset t=5 r=5, size(20) scale(0.4)

example 3

Add a second histogram.

grinset t=5 20, size(20) scale(0.4): histogram price, percent

example 4


Main changes:

29apr2023 (version 1.0.1)
- options size(), scale(), and name() are now also allowed in Syntax 2
- it now also possible to modify insets other than the inset added last
- the scheme of the main graph was only passed through to first inset, but not
  to subsequent insets; this is fixed
- option name() returned error if position other than 0 0 was specified; this
  is fixed
- in Syntax 1, positioning of inset could go wrong because xsize/ysize was not
  passed through correctly; this is fixed

27apr2023 (version 1.0.0)
- released on github

About

Stata module to add a graph as an inset to another graph

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published