Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Make dots of grid lines in log log scatter plot reflect units

    Dear all,
    I would like to create a plot with logarithmic axes and grid lines whose dots reflect the units.
    For example, consider the following plot, generated by

    sysuse auto
    tw scatter price mpg, yscale(log) xscale(log) xlabel(10 100, grid) ylabel(1000 10000)

    Click image for larger version

Name:	Zwischenablage01.jpg
Views:	1
Size:	49.4 KB
ID:	1718850


    I would like the dots of the grid lines reflect the units, i.e. their distance to each other should vary according to the logarithmic axes. I would like to set the number of dots to 9 per interval (in this example this might look odd, but in my actual plot I will have more powers of 10 per axis).

    Is this possible? Any help would be greatly appreciated.

  • #2
    I think you could get those only by generating the dot coordinates as new data.

    Comment


    • #3
      Thank you, Nick, for your reply and assessment!

      Comment


      • #4
        Not what you're asking quite, but in nearby territory:

        Code:
        webuse grunfeld , clear
        niceloglabels invest, style(125) local(yla)
        niceloglabels mvalue, style(125) local(xla)
        scatter invest mvalue, ysc(log) xsc(log) yla(`yla', grid glp(solid) glc(gs12)) xla(`xla', grid glp(solid) glc(gs12)) aspect(1)
        What's in common: a grid that is designed to work well on logarithmic scale.

        The trade-off with a grid I take to be that it should be prominent enough to fulfil its role of guiding the reader and subdued enough not to interfere with showing the data. In Stata 18 grid lines default to dashed, which I don't like myself, but the more crucial point is that you can tune line pattern, line color and line width.

        niceloglabels is from the Stata Journal. In its terms you seem to be asking for a style 123456789, which I have not implemented for the simple if personal reason that I've never wanted it.

        .
        Code:
         search niceloglabels, sj
        
        Search of official help files, FAQs, Examples, and Stata Journals
        
        SJ-20-4 gr0072_1  . . . . . . . . . . . . .  Software update for niceloglabels
                (help niceloglabels)  . . . . . . . . . . . . . . . . . . .  N. J. Cox
                Q4/20   SJ 20(4):1028--1030
                new unitfraction option has been added and code tweaked to fix
                two small occasional puzzles
        
        SJ-18-1 gr0072  . . . . . . . Speaking Stata: Logarithmic binning and labeling
                (help niceloglabels)  . . . . . . . . . . . . . . . . . . .  N. J. Cox
                Q1/18   SJ 18(1):262--286
                introduces the niceloglabels command for helping (even automating)
                label choice

        Comment

        Working...
        X