Stata: Data Analysis and Statistical Software
   >> Home >> Resources & support >> FAQs >> Changing the format of data for your axes
Note: This FAQ is relevant for users of releases prior to Stata 8.

How can I change the format of data for my axes?

Title   Changing the format of data for your axes
Author Jeremy Wernow, StataCorp
Date December 1999; minor revisions March 2001

To change the format of a number (or date) on an axis of a graph, you must first change the format of the variable itself.

For example:

 .  set obs 10

obs was 0, now it is 10

 . gen x = uniform()

 . gen y = uniform()

(These commands will generate 10 random values for variables x and y. The values generated will be between 0 and 1.)

 . list

              x          y 
   1.  .1369841   .2551499  
   2.  .6432207   .0445188  
   3.  .5578017   .4241557  
   4.  .6047949   .8983462  
   5.   .684176   .5219247  
   6.  .1086679   .8414094  
   7.  .6184582   .2110077  
   8.  .0610638   .5644092  
   9.  .5552388   .2648021  
  10.  .8714491   .9477426  

 . describe

 Contains data
   obs:            10                          
  vars:             2                          
  size:           120 (99.9% of memory free)
 ------------------------------------------------------------------------
               storage  display     value
 variable name   type   format      label      variable label
 ------------------------------------------------------------------------
 x               float  %9.0g                  
 y               float  %9.0g                  
 ------------------------------------------------------------------------
 Sorted by:  
      Note:  dataset has changed since last saved

 . graph y x
 
 . format x y %6.2f

 . list

           x       y 
   1.   0.14    0.26  
   2.   0.64    0.04  
   3.   0.56    0.42  
   4.   0.60    0.90  
   5.   0.68    0.52  
   6.   0.11    0.84  
   7.   0.62    0.21  
   8.   0.06    0.56  
   9.   0.56    0.26  
  10.   0.87    0.95  

 . describe

 Contains data
   obs:            10                          
  vars:             2                          
  size:           120 (99.9% of memory free)
 ------------------------------------------------------------------------
               storage  display     value
 variable name   type   format      label      variable label
 ------------------------------------------------------------------------
 x               float  %6.2f                  
 y               float  %6.2f                  
 ------------------------------------------------------------------------
 Sorted by:  
      Note:  dataset has changed since last saved

 . graph y x

Note: The changes in the display format are now reflected on the graph axes.

Bookmark and Share 
FAQs
What's new?
Statistics
Data management
Graphics
Programming Stata
Mata
Resources
Internet capabilities
Stata for Windows
Stata for Unix
Stata for Mac
Technical support
Like us on Facebook Follow us on Twitter Follow us on LinkedIn Google+ Watch us on YouTube
Follow us
© Copyright 1996–2013 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index   |   View mobile site