Announcement

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

  • Insert vertical space in a heatmap

    Dear Stata users,

    I am trying to create a heatmap and would like to include vertical spacing on the y-axis. However, I have been unable to achieve this. I would greatly appreciate any advice or suggestions on how to accomplish this.

    To illustrate what I am aiming for, I have included a picture that I produced in PowerPoint as an example of how it should look. The data and code is provided below.

    Thank you in advance for your help!

    Best,
    Mario Liebensteiner

    Click image for larger version

Name:	Example.png
Views:	2
Size:	74.7 KB
ID:	1770901

    I am using this example dataset:

    country value sort_h
    FR .66 3
    FR .55 2
    FR .22 1
    AT .77 3
    AT .44 2
    AT .11 1


    My code is:

    heatplot value i.sort_h country, ///
    cuts(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1) keylabels(, interval) ///
    yscale(noline) ///
    ylabel( 1 "ref" 2 "value 1" 3 "value 2" , nogrid) ///
    xlabel(, nogrid) ///
    color(inferno, reverse) ///
    xtitle("") ytitle("")

    Attached Files

  • #2
    This is very likely to be annoying as well as irrelevant to the question, but a heat map for six values of a numeric outcome for two categorical predictors?

    I recommend strongly a simple graph or dot chart.

    Comment


    • #3
      I have 24*28 = 672 datapoint per heatmap. This here is just for simplicity.

      Comment


      • #4
        Understood, but we never know your real question unless and until you tell us what it is.

        I think a heatmap for such data is unlikely to be helpful, but then the objections are different, At a minimum row and column order need optimisation. Each tile will be very small and you want to squeeze them further.

        I have had not too bad results for multiple bar charts of similar complexity, but it's usually a struggle, whatever you do.

        Comment


        • #5
          Nick, thank you for pointing this out. I just wanted to keep it as simple as possible.


          To everybody: I managed to achieve what I wanted. The trick was simple, but it took me long to find out. I simply added a missing-value entry for each country where the sorting variable had a value of 2.


          To provide some context, I use the heat maps to show and compare estimates of marginal and average emissions factors for different electricity markets in Europe. Here are the heat maps:

          Click image for larger version

Name:	hm.png
Views:	1
Size:	138.8 KB
ID:	1770916




          Comment


          • #6
            Now that time of day has been revealed as one predictor, I would want to try time series plots and in particular front-and-back plots. fabplot is a suitable search term for the forum.

            Comment


            • #7
              Thank you indeed for the hint! I'll see into it. If I am able to produce a nice graph, I will post it here.

              Comment

              Working...
              X