Announcement

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

  • How to generate a gradient colored legend after a custom graph in Stata?

    This is a re-post. Somehow I have been unable to see my first post. I apologize for that.
    --
    This post is related to my previous query:

    https://www.statalist.org/forums/for...-maps-in-stata

    To simplify matters: let's suppose one has a scatter plot as follows:



    Code:
     clear set  obs 10  gene x = _n  gene y = _n  scatter x y, xsize(8) aspect(0.7)
    which will look like this:

    Click image for larger version

Name:	scatter.png
Views:	3
Size:	49.6 KB
ID:	1649972




    The idea is to plot on the left-hand side a custom gradient bar. For example:

    Click image for larger version

Name:	Selection_667.png
Views:	2
Size:	20.1 KB
ID:	1649973


    I haven't figured out something straightforward that generate that gradient colored legend. Does anyone have experience with that? Any suggestions?


    All the best,

    Tiago
    Attached Files

  • #2
    Tiago Pereira
    To the best of my knowledge there isn't a way to map a gradient to values in the way I think you are wanting to. You'd either have to define distinct groups for each of your points and then map each point to a color, or might be able to make contourplots do something to provide some type of related output.

    Comment


    • #3
      Thank you, William.

      I thought I could do that using colorpalette:

      Code:
      colorpalette, vertical: DarkCyan White, ipolate(10) / #bd1e24 White , ipolate(10)

      Manually editing the graph to change its size and then using -combine- to combine both graphs. However, colorpalette has no ysize() xsize() options

      Any thoughts are welcome.

      All the best,

      Tiago

      Comment

      Working...
      X