Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: Graphing: How to suppress labels on second y axis


From   "McDermaid, Cameron" <Cameron.McDermaid@ottawa.ca>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Graphing: How to suppress labels on second y axis
Date   Thu, 30 Sep 2010 10:41:02 -0400

I've made a tweak to Nick's suggestion below.  One rationale for using 2 axes was that the primary Y axis is one scale that can vary with the data and the second Y axis is fixed from 0 -1 . Using Nick's suggested script below uses the alert's actual value (missing, 1) is plotted on the primary Y axis and is often out of scale as to be not easily seen, depending on the line graph data.

What I've done is adjust the alert value (1) to the maximum value of the data in the line plot then back to 1 once the plot is done.

e.g. 

quietly: sum `lev'normalized 
local maxval: display `r(max)'
replace alert`lev'= alert`lev'*`maxval'  /*adjusts alert to maximum value in line plot */

do the plot with || dropline `lev'normalized adm_date if alert`lev'<., ms(i)

replace alert`lev'=alert`lev'/`maxval'  /*adjusts back to 1 for the next plot loop*/

This seems to be working.  Thanks again to Nick for a kick in the right direction.


- cam

--
Cameron McDermaid MHSc
Epidemiologist
Ottawa Public Health
100 Constellation Cr, Ottawa ON K2G 6J8
vox: 613.580.6744x15321
fax: 613.580.9601

Not everything that can be counted counts; and not everything that counts can be counted - George Gallup




> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of McDermaid, Cameron
> Sent: September 30, 2010 8:32 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: Graphing: How to suppress labels on second y axis
> 
> Thanks Nick
> 
> This worked splendidly.  I used the dropline rather than the tick option
> you suggested earlier because the data appeared more visually
> independent using the dropline.
> 
> Thanks again for your help.
> 
> - cam
> 
> --
> Cameron McDermaid MHSc
> Epidemiologist
> Ottawa Public Health
> 100 Constellation Cr, Ottawa ON K2G 6J8
> vox: 613.580.6744x15321
> fax: 613.580.9601
> 
> The plural of anecdote is data -  Raymond Wolfinger
> 
> 
> 
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> > statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> > Sent: September 29, 2010 3:09 PM
> > To: 'statalist@hsphsun2.harvard.edu'
> > Subject: st: RE: RE: Graphing: How to suppress labels on second y axis
> >
> > Alternatively, try
> >
> > twoway line `lev'normalized adm_date,
> > by(hospital, col(1) legend(off)
> > note(" ") title("`lev' Syndrome", size(medium)))
> > name(Normalized_`lev')
> > ylabel(#4, angle(0) labsize(vsmall))
> > ytitle("Proportion of Cases (%)")
> > xtitle("Date")
> > xlabel(#10, labsize(small))
> > || dropline `lev'normalized adm_date if alert`lev', ms(i)
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> > Nick Cox
> >
> > Why do you need a second y axis any way? For example, you could add
> axis
> > ticks to the x axis to signal times of alert events or a grid of
> xli().
> >
> > McDermaid, Cameron
> >
> > Stata 11 SE
> >
> > I am trying to suppress labelling on a second y axis in a combined
> > graph.  The graph is normalized patient flow vs. dates as a line graph
> > (yaxis 1) with a dropline graph showing alert events (yaxis 2). The
> > alert events are dichotomous and a maximum of 1 can appear per day so
> a
> > scale for the alerts (0-1) isn't really useful.
> >
> > The working graph command is as follows from a foreach command (hence
> > the local macro `lev'):
> >
> > twoway line `lev'normalized adm_date, by(hospital, col(1) legend(off)
> > note(" ") title("`lev' Syndrome", size(medium)))
> name(Normalized_`lev')
> > yaxis(1) ylabel(#4, angle(0) labsize(vsmall) axis(1))
> ytitle("Proportion
> > of Cases (%)") xtitle("Date") xlabel(#10, labsize(small)) || dropline
> > alert`lev' adm_date, yaxis(2) msymbol(i) ylabel(0(1)1,axis(2))
> >
> > If I use ylabel(none, axis(2)), I get the following error message:
> > "incompatible types   may not assign class to double" and the process
> > stops.  My understanding was that I added the rule (none) and the
> > suboption axis(n) to designate the axis to which the rule is applied.
> >
> > Any thoughts on how to suppress labelling on axis 2 would be
> > appreciated.
> >
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> 
> This e-mail originates from the City of Ottawa e-mail system. Any
> distribution, use or copying of this e-mail or the information it
> contains by other than the intended recipient(s) is unauthorized.
> If you are not the intended recipient, please notify me at the
> telephone number shown above or by return e-mail and delete
> this communication and any copy immediately. Thank you.
> 
> Le présent courriel a été expédié par le système de courriels de
> la Ville d'Ottawa. Toute distribution, utilisation ou
> reproduction du courriel ou des renseignements qui s'y trouvent
> par une personne autre que son destinataire prévu est interdite.
> Si vous avez reçu le message par erreur, veuillez m'en aviser par
> téléphone (au numéro précité) ou par courriel, puis supprimer
> sans délai la version originale de la communication ainsi que
> toutes ses copies. Je vous remercie de votre collaboration.
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

This e-mail originates from the City of Ottawa e-mail system. Any 
distribution, use or copying of this e-mail or the information it 
contains by other than the intended recipient(s) is unauthorized. 
If you are not the intended recipient, please notify me at the 
telephone number shown above or by return e-mail and delete 
this communication and any copy immediately. Thank you.

Le présent courriel a été expédié par le système de courriels de 
la Ville d'Ottawa. Toute distribution, utilisation ou 
reproduction du courriel ou des renseignements qui s'y trouvent 
par une personne autre que son destinataire prévu est interdite. 
Si vous avez reçu le message par erreur, veuillez m'en aviser par 
téléphone (au numéro précité) ou par courriel, puis supprimer 
sans délai la version originale de la communication ainsi que 
toutes ses copies. Je vous remercie de votre collaboration.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index