Code Monkey home page Code Monkey logo

scottplot's Introduction

ScottPlot

CI Discord

ScottPlot is a free and open-source plotting library for .NET that makes it easy to interactively display large datasets. The ScottPlot Cookbook demonstrates how to create line plots, bar charts, pie graphs, scatter plots, and more with just a few lines of code. The ScottPlot Demo shows how to create plots in GUI environments with advanced interactive behaviors. ScottPlot supports Windows Forms, WPF, Console, Blazor, Avalonia, Eto, Notebooks, and more!

Visit https://ScottPlot.NET for documentation and additional information

Contributing: We welcome contributions from the community! We invite contributions from anyone, including developers who may be new to contributing to open-source projects. Visit https://ScottPlot.net/contributing/ to get started!

License: ScottPlot was created by Scott W Harden and enhanced by many contributions from the open-source community. It is provided under the permissive MIT license and is free to modify and use for any purpose.

If you enjoy ScottPlot give us a star! โญ

scottplot's People

Contributors

aespitia avatar arthurits avatar bambooxx avatar bclehmann avatar brianatzetica avatar bukkideme avatar drolevar avatar endreew avatar excustic avatar fruchtzwerg94 avatar gray-lab avatar handsomegoldenknight avatar hellfo avatar kritner avatar kromignon avatar maoyao233 avatar mcf avatar morningkyle avatar nicolaslairnet avatar padanian avatar peterdavidson avatar rafntor avatar rayffer avatar silent0wings avatar stendprog avatar sulivanganter avatar swharden avatar tilation avatar unsigned-ru avatar zrolfs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scottplot's Issues

Modify ticks and real time on the chart

Hi,

I'm currently using your library to make some live sensor chart. It's work fine, but I have two questions.
First, is there a way to modify programmactly the ticks the chart? (For example, just show four ticks instead of many ticks?)
And second, Is it possible to put real time (in DateTime) in the axis instead of real time in double?

Picture of the problem: Picture.zip

Thanks in advance!

clean-up demos folder

The majority of code in this repo is now demos. Should demos get their own repo? Perhaps we can keep 1 master demo here that demonstrates all core features?

version specification in readme

From the latest readme file , there are three main versions of ScottPlot, while v2 and v3 are in actively developed.

Would you please add some spec on these versions to get an introduction about features difference between them?

draggable axis line limits

Perhaps there should be possibility to keep the draggable line within plot area? Right now if I drag a line out of plot area, I can never access it again - that is of course if I have defined my axis region manually and is rendered every iteration in such area.

Maybe defining V or H lines like:

public void PlotVLine(double x, Color? color = null, double lineWidth = 1, string label = null, bool draggable = false, bool bounds = false, double xMin = 0, double xMax = 50)

support the lowest possible .NET Framework (4.5)

I saw ScottPlot at the nuget and wanted to be the first downloader.
Howerver, I failed since .net framework version 4.5/4.6 lower than that one you build(4.7?).

I do suggest you to make the minimum version reset to be 4.5. It should be work as I successful run the source code v3.

support "lineStyle" arguments

You already implemented selectable marker shapes for Plots, which is great! What do you think, could it be possible to also implement dashed line types (like dotted, dash, dash/dots, etc)?
In this case, I think the legend section could automatically show marker shapes / line types, depending on the following conditions:

  1. We have larger than zero for both marker shapes and line widths: show both markers and (dashed) lines in legend section.
  2. If either the line width or the marker shape zero valued, reflect this info in legend: for example in case of zero sized marker, only show line. In the recent Legend behavior, the marker shows up even if we only plot the line and set marker size to zero.

I will really try to find some time later on to do some real contribution to the code base, sorry that recently I can only provide such limited help...

GetPixel bug

Settings.cs#L365

Take the X as example,
int xPx = (int)((locationX - axis[0]) * xAxisScale);
should be
int xPx = (int)((locationX - axis[0]) * xAxisScale)+ dataOrigin.X;
๏ผŸ

This fix cause new problem when render new graph. Sad!

Find figure margins

Hi,

I'm using your library in a spectrum analysis app. The image is shown inside a PictureBox and
I want to print x-axis units on mouse-click.

"fig1.xAxis.GetUnit" works fine, but pixels delivered by PictureBox1>MouseClick event
refers to the left edge of the box.

Is there a way to find figure margins? I found only "fig.FramePad", which can only write.

Thanks in advance!

manually define grid spacing

modify Grid() to add arguments which allow the user to manually define grid spacing (or send null for automatic). X and Y grids should be controlled independently.

configurable legend location

Further to #10 issue closed on May, I was wondering whether it would be possible to extend the feature, but positioning the legend frame on other corners too, like top left corner.
I'd like to help with coding, if it's ok with Scott.

draggable axis lines

I use the plt.data.AddVertLine() function add two vertical line to set a range between the two lines.
By now I have to add other control for the user to manipulate to set the X position of the line.
Is there any plan to add feature for manipulating the the line position directly?

customizable mouse functions

My question is that, would it be difficult to add a new method to the ScottPlotUC User Control, which could give us access to disable/modify the pre-programmed mouse bindings?
In some cases, I would like to program additional features with mouse events for these very handy controls, but the existing mouse events do not let it happen.
Second question, what is the most simple workaround to custom handle for example mouse left double clicks?
thanks!

hover over a data point to display its value

Currently only data values (points and lines) are plottable.
Support the addition of text to ScottPlot figures using something like:

plt.data.AddText(string message, double xPos, double yPos

Strategy

Create a Text PlottableThing:
https://github.com/swharden/ScottPlot/blob/master/src/ScottPlot/Plottables.cs

Add a line here which gets called every time Render() is called:
https://github.com/swharden/ScottPlot/blob/master/src/ScottPlot/Figure.cs#L89-L99

Write RenderText() similar to other functions here:
https://github.com/swharden/ScottPlot/blob/master/src/ScottPlot/Figure.cs#L435-L463

plot bar graphs

add support for bar graphs and methods to generate histograms

scrollwheel zoom to cursor

Currently the scrollwheel zooms in/out to the center point of the axes. Modify this behavior to center where the cursor is. This will let you hover over a region of interest and zoom into that region without having to move the cursor.

ticks display very large and very small numbers poorly

We often need to plot very large or very small numbers. ScottPlot's recent version is not able to render such plots. If we use large numbers, it starts to consume up GBs of RAM, eventually crashing the app.
double[] xs = new double[] { 1, 2, 3, 4, 5 };
double[] ys = new double[] { 1E15, 4E15, 9E15, 16E15, 25E15 };
scottPlotUC1.plt.PlotScatter(xs, ys);
scottPlotUC1.Render();
If we try to display very small numbers, it works, but not showing the numbers at the axis ticks. Could this be fixed somehow? I think the fix should contain adding new features to the package, we could call it like "AxisScaling". Here we could set the formatting of the axis numbers (number of digits, precision, scientific/engineering/normal/... number formats )...
What do you think?

edit: my temporary workaround is that, I divide the large array by 1E15, then name the axis as "1E15 unit".

To integrate into your code another code

Hi, I use AudioMonitorFFT
How add this code in your class SWHearFFT
Code:

class Tuner
{
	BufferedWaveProvider bufferedWaveProvider = null;
	public bool isSound;
	Dictionary<string, float> noteBaseFreqs = new Dictionary<string, float>()
		{
			{ "C", 16.35f },
			{ "C#", 17.32f },
			{ "D", 18.35f },
			{ "Eb", 19.45f },
			{ "E", 20.60f },
			{ "F", 21.83f },
			{ "F#", 23.12f },
			{ "G", 24.50f },
			{ "G#", 25.96f },
			{ "A", 27.50f },
			{ "Bb", 29.14f },
			{ "B", 30.87f },
		};
		
	public string ReturnNote { get; private set; }

	public void StartDetect(int inputDevice)
	{
		WaveInEvent waveIn = new WaveInEvent();

		waveIn.DeviceNumber = inputDevice;
		waveIn.WaveFormat = new WaveFormat(44100, 1);
		waveIn.DataAvailable += WaveIn_DataAvailable;

		bufferedWaveProvider = new BufferedWaveProvider(waveIn.WaveFormat);

		// begin record
		waveIn.StartRecording();

		IWaveProvider stream = new Wave16ToFloatProvider(bufferedWaveProvider);
		Pitch pitch = new Pitch(stream);

		byte[] buffer = new byte[8192];
		int bytesRead;
		
		do
		{
			bytesRead = stream.Read(buffer, 0, buffer.Length);

			float freq = pitch.Get(buffer);

			if (freq != 0)
			{
				ReturnNote="Freq: " + freq.ToString() + " | Note: " + GetNote(freq);
			}

		} while (bytesRead != 0 && !(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

		// stop recording
		waveIn.StopRecording();
		waveIn.Dispose();
	}

	void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
	{
		if (bufferedWaveProvider != null)
		{
			bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
			bufferedWaveProvider.DiscardOnBufferOverflow = true;
		}
	}

	public string GetNote(float freq)
	{
		float baseFreq;
		foreach (var note in noteBaseFreqs)
		{
			baseFreq = note.Value;
			for (int i = 0; i < 9; i++)
			{
				if ((freq >= baseFreq - 2.1925) && (freq < baseFreq + 2.1925) || (freq == baseFreq))
				{
					return note.Key + i;
				}
				baseFreq *= 2;
			}
		}
		return null;
	}
}

Please help

add data export option to right-click menu

This feature would be useful for data-logging programs that display new data as it's measured.

This idea was initially raised by @bukkideme in #49

CSV output makes a lot of sense. It's easy to parse, and easy to load right into programs like Excel.

It gets a little complicated because a single plot may have several plottables, and they can have different X positions. Instead of XYYYY, the output probably needs to be XYXYXYXY.

create a WPF user control

I can run your WinForm demos, I want to transfer these demos to WPF.
Is there any problem if I do so? I have check your quick-start WPF demo, but it is quite simple so I do not know in the case of more complex demos as AnimatedSin, ScottPlot also supports?

Arbitrary non-orthogonal axis

Like in the example below, it would be great to have additional non-orthogonal axis, for functions z=f(x,y) where x,y are horizontal and vertical axis

psy

Add skip types to Clear()

sometimes you want to plot a signal and decorate it with markers and have an easy way to clear them so it would be nice to:

plt.Clear(scatter: False);

refactor tick mark module

Ticks don't display well for large and small numbers (#54) and sometimes ticks overlap axis labels (#47).

These issues have been fixed but the tick generation module could be better. Refactoring/rewriting Ticks.cs will streamline tick generation and make ticks easier to customize in the future.

refactor user control (to prep for WPF)

Now that we want to create user controls for both winforms and WPF (#42), the winforms user control should be refactored to pull-out as much code/functionality as possible and place it in a platform-independent user control class.

As noted by @Padanian in pull #40, part of this refactoring should be streamlining invocation of events by using inline null checks:

var handler = MouseMoved;
if (handler != null)
    handler(this, e);

should become something like this (everywhere it's used):

MouseMoved?.Invoke(this, e);

histogram

add Plot.PlotHistogram() which takes a 1D dataset, optional arguments about bin size and limits and normalization, creates the bins/counts, then just calls Plot.Bar(bins, counts)

... or consider making a ScottPlot.Histogram class? It may be easier to just Plot.Bar(hist.bins, hist.counts). This also makes it easy to package different features like placing limits at the 95 percentile, or adding stats to test for normal distribution

plt.Legend()

To whom it may concern,

This is really a great visualization library in C#
and I wonder if there is any new update on "Legend Function".
Legend, a rectangular showing the title of each Lines on the Figure.

Thank you and looking forward to your precious reply.
Best regard

Issue with SplitContainer - cannot move splitter after first movement (Winform)

How to reproduce the issue:

  1. open a Winform project in Visual Studio (i used v2019)
  2. Drop a vertical SplitContainer into the Form.
  3. Drop a "scottPlotUC" control into the right Panel.
  4. Set Dock property to Fill for this plot control.
  5. Compile and run the project.

Discover the following: when you drag and move the splitter bar, it moves as expected. However, only once! The next attempt fails. The only way to make the vertical splitter movable again, is to resize the whole Form window, by changing its width or height by the mouse. After such Window resize, you can again move the splitter. But only once!
What causes this behaviour? If I drop the simple MS Chart into the right Panel of the SplitContainer, it behaves as expected.
Thanks if you can fix this, and also thanks for the very useful package!
SiC_VQ_data_analyzer.zip

don't display null labels in legend

It would be great if the legend didn't show null plot labels.

@Padanian do you want to fix this one since you're the legend expert?

var plt = new ScottPlot.Plot(width, height);
plt.PlotScatter(dataXs, dataSin);
plt.PlotScatter(dataXs, dataCos, label: "cos");
plt.PlotVLine(20);
plt.Legend();

58_StyleDefault

zoom in and out by mousewheel

Hi~ This is a great plot library under .net framework.
Is there an operation that optimizes the ability to zoom in or out with event 'mousewheel'?

legend shadow

@Padanian you did an awesome job adding legend location functionality (#39). Do you think a shadow would be good to have too? We are already drawing a solid frame so it doesn't seem like it would be hard to implement... maybe just a bool to turn it on and off?

Let's make the shadow fall to the lower right so we don't have to go through the trouble of making a shadowLocation object ๐Ÿ™ˆ

If you think it's over the top we can probably let it go. I just thought it might be a nice touch! It would take a few lines here:
https://github.com/swharden/ScottPlot/blob/dba76dd07a61f910c9d034b8b42474068733670a/src/ScottPlot/Renderer.cs#L167-L172

Some examples:
https://www.google.com/search?q=matplotlib+legend+shadow&tbm=isch

custom marker shapes

Recently plt.PlotScatter() only gives option to change size and color of the markers. What about giving extra options, like filled and none filled markers with different shapes? Using different markers and not only colors greatly increases the readability of scientific charts/graphs.
I used a lot GLE in the past, which is a scripting language for vector graphic plots. Maybe it can give you some good inspiration during further dev of ScottPlot? I link here the optional marker types in this environment: http://glx.sourceforge.net/examples/other/wallx.html

Off topic in this very feature request, but since I mentioned GLE, I would like to ask your opinion about a possible interfacing (any kind or level) between ScottPlot and GLE? Just to explain what I think of, see my very primitive past attempt to do something similar using LabVIEW: https://forums.ni.com/t5/Community-Documents/Interface-to-Graphics-Layout-Engine-GLE-to-create-publication/ta-p/3592762?profile.language=en

add frequency detection to audio monitor demo

I get a lot of inquiries related to frequency detection related to the audio monitor demo. Modify this demo to implement frequency detection and demonstrate how place a vertical line at peak frequency and move it with every update.

fix bar plot rendering issues

you might have to disable anti-aliasing while drawing the rectangles then re-enable it

or try drawing empty rectangles on top of filled ones

image

Support candlestick and OHLC charts

The Japanese candlestick chart is the cornerstone of financial charting. It would be great to add support for this chart type to ScottPlot, giving .NET uses a free and open-source way to interactively display financial data.

Data over time is binned, and the values for each bin are analyzed to become each candle:

  • the wick (line) represents min/max value
  • the body (rectangle) represents enter/exit value
  • the color represents if the price rose (enter<exit) or fell (enter>exit)

image

call AxisAuto automatically

If the user doesn't explicitly set the axes with plt.AxisAuto() or plt.Axis(), automatically call plt.AxisAuto() before the first render that contains data.

axis label gets overlapped when tick labels increase in length

I am experiencing overlapping of the axis labels with the axis markers/numbers at certain zoom levels (when zoomed in).
I wonder if it is possible to fix this problem, like auto increase the gap between axis and its label based on the axis markers' length...? I attach two screenshots, the first showing no zoom, the second the zoomed state.
Thanks!
Best Regards,

edit: using Winform, ScottPlot 3.0.6

ScottPlot_axis_label_ok
ScottPlot_axis_label_Overlaps

step plot

add an argument to XY plots to draw connecting lines as steps. This will be ideal for CPH curves. Matplotlib uses its own step() function but I think adding a simple bool argument to plotScatter() is simpler...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.