Getting the const value of Plot.Axes.GetLimits of initial xMax/Right instead of viewport xMax
Hi Scott,
I was wondering if there is a bug with this implementation (https://github.com/ScottPlot/ScottPlot/issues/2840) or if it was by design, or I missed something...?
Regarding those values, I know that this will give the values, as by design when fully zoomed out:
AxisLimits limits_test = formsPlot2.Plot.Axes.GetLimits();
double xMin = limits_test.Left;
double xMax = limits_test.Right;
double yMin = limits_test.Bottom;
double yMax = limits_test.Top;
Debug.WriteLine(xMin.ToString());
Debug.WriteLine(xMax.ToString());
Debug.WriteLine(yMin.ToString());
Debug.WriteLine(yMax.ToString());
// My temp variable.
Global.SampleMaxLimit_Calculated = limits.Right;
The problem:
If you are zoomed in, it doesn't give out the initial .Right value any more, and instead gives out the Right value inside the viewing area.
Question:
Is there a way to get that constant Right value of the full plot when zoomed out like I think it did with version 4?
Or have I missed something in the conversion to v5?
Explaining it more:
This following image is using the XRange.Max, but I found that limits.Right also had the same result: (about 30 seconds)
CoordinateRect rect = new CoordinateRect(left: 0, right: limits.XRange.Max, bottom: 0, top: 1);
I found a work around to store that initial xMax value prior to any zooming, but I was wondering if I was missing something?
This question is just related to inserting spectral images as per my question last month: https://github.com/ScottPlot/ScottPlot/issues/4051 I have them placing correctly, but without the temp value or being fully zoomed out, wasn't stretching the image according to the full width of the plot.
This following image is using the following (working code): (about 15 seconds)
CoordinateRect rect = new CoordinateRect(left: 0, right: Global.SampleMaxLimit_Calculated, bottom: 0, top: 1);
Basically what I'm using for this:
// Global.SampleMaxLimit_Calculated is caluculated prior to this code, as is the loading of the other graphing data.
// Get the data for the spectral view
(double[] audio, int sampleRate) = ReadMono(Audio_Filename1);
int fftSize = 4096;
int targetWidthPx = 3000;
int stepSize = audio.Length / targetWidthPx;
Global.sg = new SpectrogramGenerator(sampleRate, fftSize, stepSize, maxFreq: 3000);
Global.sg.Add(audio);
Global.sg.SetColormap(Colormap.Viridis);
System.Drawing.Bitmap bmp = Global.sg.GetBitmap(intensity: 5);
Global.ms = new MemoryStream();
bmp.Save(Global.ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bitmapBytes = Global.ms.ToArray();
Global.tempbmp = new ScottPlot.Image(bitmapBytes);
// Using this now.
CoordinateRect rect = new CoordinateRect(left: 0, right: Global.SampleMaxLimit_Calculated, bottom: 0, top: 1);
// Instead of this
//CoordinateRect rect = new CoordinateRect(left: 0, right: limits.XRange.Max, bottom: 0, top: 1);
Anyway, probably too much information to share, but just my thoughts and ponderings. Hopefully someone else can benefit from this.
Cheers, Steve