Replies: 1 comment
-
|
Hi @Terebi42, thanks for your question! By answering it here I hope to help your project while also sharing answers for future users who may have the same question. Horizontal legendThis suggestion is a good one and has been made before (#580). It is currently triaged as a moderate priority task (#1028) and I am unlikely to work on this soon. It's open for contribution though, and is on the list of possible hacktoberfest contributions #1274 How to place a legend outside the plot areaThis solution is not elegant, but it works and offers a lot of flexibility. I added an item on the triage list (#1028) to hopefully make it easier to achieve this entirely within ScottPlot. using System.Drawing;
using ScottPlot;
// render plot and legend as separate images
var plt = new Plot(400, 300);
plt.AddSignal(DataGen.Sin(51), label: "sin");
plt.AddSignal(DataGen.Cos(51), label: "cos");
Bitmap bmpPlot = plt.GetBitmap();
Bitmap bmpLegend = plt.RenderLegend();
// create a large image and place the plot and legend images onto it
Bitmap bmp = new Bitmap(bmpPlot.Width + bmpLegend.Width, bmpPlot.Height);
using Graphics gfx = Graphics.FromImage(bmp);
gfx.Clear(Color.White);
gfx.DrawImage(bmpPlot, 0, 0);
gfx.DrawImage(bmpLegend, bmpPlot.Width, (bmp.Height - bmpLegend.Height) / 2);
bmp.Save("demo.png"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
For some graphs there is no good place within the data to render.
Allow for horizontal layout instead of vertical. This would allow for placements in some cases inside the graph in a less obtrusive location
Add some location anchors inside the image, but outside the data area. Out side of the on any of the 4 sides would be good (top and bottom using the horizontal option above)
I am aware of the LegendBitmap() function, but it doesn't serve my use case which is just a single generated static image.
Beta Was this translation helpful? Give feedback.
All reactions