Announcement

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

  • Questions about contour plots

    I have three problems when plotting a contour graph in Stata 16.0 for Windows (revision 02 Jul 2019). This is not the latest update, I know, but have to stick to this version. If this has been fixed already, I apologize.

    1. The legend doesn't seem to obey the legend(off) option. I understand that technically its role is more like the scale or an axis. Can it be fully switched off?
    I have tried to probe it using the interactive Graph editor, and managed to switch off the numerical values, but the rainbow ribbon stays on no matter what. I am seeing a menu item 'Key_Contour properties' which looks like something lacking translation text, and behind it a dialog which has checkbox for 'Hide plot'. It would make sense to have 'Hide legend' or 'Hide keys' there instead of or in addition to.

    2. When plotting the chart, Stata first plots it fully, but then covers the top half with a flat color corresponding to the lowest value. I have tried to reduce the number of levels, but it doesn't make a difference. The image below illustrates what I am getting on the screen. The same occurs when the graph is plotted on the screen and when it is exported as a file. The contour is plotted on the basis of ~1,600 points obtained after processing of a larger dataset (of 1mln+ observations). I find that by knocking out observations from the original dataset, I can obtain a more dramatic picture, which is shown below as a second image (200,000 observations, resulting in 644 points for the contour plot).

    Finally, what I find is that the problem occurs only when there are missing values in the data (on one dimension: b, which is vertical on the plot, there are no missings in the outcome - the color dimension) AND the default interpolation method is used (thinplatespline).
    • By changing the interpolation method, I am getting an undesirable plot with a large unfilled white area (expected dark blue) and some jagged edges due to that (3rd image below).
    • So I have to also drop the observations with missing components before plotting, which is not usual when plotting the data (missing values are normally disregarded automatically).
    The description of the interpolation method in the manual deals with missings in Z (the color dimension), but not in the coordinates dimension.
    For the moment I decided to drop such observations before plotting, but perhaps that could be a default behavior for the twoway command??

    3. Finally I find that despite the following three methods of interpolation are declared (thinplatespline , shepard, and none) the interpmethod option will happily take any method name, including the misspelled valid ones, such as 'shephard' or 'sheppard', as well as completely alien ones 'linear' or 'quadratic' without issuing any warning message at all. I feel there should be a warning, same approach as with the unknown colors or line widths, or even more stronger warning/error:

    sheppard interpolation method is not recognized, the none method will be used instead.

    Any thoughts and comments are welcomed.

    Thank you, Sergiy Radyakin

    Click image for larger version

Name:	G3.png
Views:	1
Size:	95.0 KB
ID:	1562695


    Click image for larger version

Name:	G3a.png
Views:	1
Size:	107.2 KB
ID:	1562696


    Click image for larger version

Name:	G3b.png
Views:	1
Size:	100.7 KB
ID:	1562697

  • #2
    1. The legend doesn't seem to obey the legend(off) option. I understand that technically its role is more like the scale or an axis. Can it be fully switched off?
    I have tried to probe it using the interactive Graph editor, and managed to switch off the numerical values, but the rainbow ribbon stays on no matter what. I am seeing a menu item 'Key_Contour properties' which looks like something lacking translation text, and behind it a dialog which has checkbox for 'Hide plot'. It would make sense to have 'Hide legend' or 'Hide keys' there instead of or in addition to.
    On #1, this not your usual legend (which is off by default). It is a contour legend, so you want the option

    Code:
    clegend(off)
    #2 and #3 still remain open for anyone with any insights. But I would suggest that Sergiy Radyakin post a reproducible example to help in understanding the problem.

    Comment


    • #3
      Thank you Andrew, clegend() is exactly what I needed to control the legend.

      I had a sense that it is not a standard legend, but didn't know how to properly name it. Unfortunately the documentation for the contour plot doesn't mention it:

      Click image for larger version

Name:	contour_options.png
Views:	1
Size:	43.3 KB
ID:	1562765

      Comment


      • #4
        Rather cryptically, you would need to navigate through -twoway options- and then to -legend options- to finally find the description of -clengend()- and -plegend()- for contour line plots..

        Comment

        Working...
        X