Virata manual

graph

Draws a chart and saves it as a web page you can open, email or embed.

What we have

  • 22 chart types, listed in the gallery
  • statistics: count, max, mean, median, min, sum
  • over(), by(), title(), ytitle() and saving()
  • each chart is one self-contained .html file with no internet needed

Coming later

  • graph twoway and graph matrix, which are refused
  • saving as PNG or SVG; graph export does not exist yet
  • 84 more of the 105 catalogue chart types

How you write it

graph <kind> [(stat)] varname [if] [weight] [, over() by() ...]

Square brackets mean optional. A vertical bar means choose one.

What it does

graph bar mpce, over(state) writes a self-contained .html file: one file, no internet connection needed, opens in any browser. Every number in it was worked out in Python before the page was written — the page only draws.

Twenty-one chart types are built. The shape of the command is the same for all of them:

See the chart gallery for all of them, each with its own page, a live example and the shape your data needs to be in.

Watch out. Every chart wants long data: one row per person or record. If your years sit in separate columns (income2004, income2006), run reshape long first.

Try it

Every example below was run after sysuse vira.sample01, clear.

. graph bar mpce, over(state)
(graph saved to graph_mpce.html)
The same thing in pandas and in R

pandas

# rendered with D3; see graph_mpce.html

R

# no R form for `graph` yet -- see docs/r-equivalents.md