title: Where to place the coordinates of text in a C# graphic bitmap
body: <p>I wrote a C# Render method that renders a heatmap onto a Grasshopper canvas. Grasshopper is a Rhino plugin that allows for a simple GUI programming interface. </p>
  
  <pre><code>protected override void Render(Grasshopper.GUI.Canvas.GH_Canvas canvas, Graphics graphics, Grasshopper.GUI.Canvas.GH_CanvasChannel channel) {
  
              base.Render(canvas, graphics, channel);
  
              if (channel == Grasshopper.GUI.Canvas.GH_CanvasChannel.Wires) {
                  var comp = Owner as KT_HeatmapComponent;
                  if (comp == null)
                      return;
  
                  List&lt;HeatMap&gt; maps = comp.CachedHeatmaps;
                  if (maps == null)
                      return;
  
                  if (maps.Count == 0)
                      return;
  
                  int x = Convert.ToInt32(Bounds.X + Bounds.Width / 2);
                  int y = Convert.ToInt32(Bounds.Bottom + 10);
  
                  for (int i = 0; i &lt; maps.Count; i++) {
                      Bitmap image = maps[i].Image;
                      if (image == null)
                          continue;
  
                      Rectangle mapBounds = new Rectangle(x, y, maps[i].Width, maps[i].Height);
                      //Rectangle mapBounds = new Rectangle(x, y, maps[i].Width * 10, maps[i].Height * 10);
                      mapBounds.X -= mapBounds.Width / 2;
  
                      Rectangle edgeBounds = mapBounds;
                      edgeBounds.Inflate(4, 4);
  
                      GH_Capsule capsule = GH_Capsule.CreateCapsule(edgeBounds, GH_Palette.Normal);
                      capsule.Render(graphics, Selected, false, false);
                      capsule.Dispose();
  
                      graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                      graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
                      graphics.DrawImage(image, mapBounds);
                      graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                      graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default;
                      graphics.DrawRectangle(Pens.Black, mapBounds);
  
                      y = edgeBounds.Bottom - (mapBounds.Height) - 4;
                  }
              }
          }
  </code></pre>
  
  <p>Currently, this render methods draws an image like this onto the canvas:</p>
  
  <p><img src="https://i.stack.imgur.com/B8u9e.png" alt="enter image description here"></p>
  
  <p>With that said, I would like to put some title text on top, and put in labels for the X and Y axis, like a standard heat map graph. However, my understanding of the <code>graphics</code> component is too limited, and I would like to request the assistance of you guys.</p>
  
  <p>I did some research, and it seems the <code>drawText()</code> method could do what I want: <a href="https://stackoverflow.com/questions/6311545/c-sharp-write-text-on-bitmap">c# write text on bitmap</a></p>
  
  <p>But I am unsure where to specify the coordinates while at the same time leaving some space on the top of the displayed graph to put the title text.</p>