Comments (22)
It would be great to be able to plot dotted, dashed, and other patterns of lines. I think the only plottable objects which would benefit from this are scatter plots and axis lines.
This should be easy to implement too. Lines are drawn with Pen
objects. These objects are created here for scatter plots and here for axis lines. Pen
objects are currently all set to draw solid lines, but they can be easily customized to draw different patterns by setting their DashStyle
:
pen.DashStyle = DashStyle.DashDot;
Once implemented, the legend code could be updated to draw proper dash styles too.
The website
http://csharphelper.com/blog/2015/02/draw-dashed-lines-with-different-styles-in-c/ displays some common styles:
from scottplot.
from scottplot.
from scottplot.
from scottplot.
The legend could just show line (with its DashStyle) and place a single marker above it (if markers are being used).
# python example
import matplotlib.pyplot as plt
import numpy as np
xs = np.arange(20)
ys = np.sin(np.pi*2*xs/len(xs))
plt.plot(xs, ys, label='data', linestyle=':',
marker='v', markerfacecolor='r', markeredgewidth=0)
plt.legend()
plt.show()
from scottplot.
from scottplot.
@Padanian did you try to post a picture with your last message? I'm viewing the GitHub issue page #59 and no image appeared with your last post.
from scottplot.
Yes, this one
Do I need to redefine dashes and spaces?
from scottplot.
It looks like a pretty good start! Let's add some custom dash patterns into the mix so we can always add/modify patterns later. I think you make custom patterns like:
Pen pen = new Pen(Color.Black, 5);
float[] dashValues = { 5, 2, 15, 4 };
pen.DashPattern = dashValues;
from scottplot.
... actually, maybe all our patterns should be custom? Maybe the dash values are some multiple of line width?
from scottplot.
from scottplot.
from scottplot.
Yes, all of them need to be custom, to properly render. I’m working on it. Will commit later tonight.
Sounds great! Thanks for your contribution! It's looking great already.
from scottplot.
Another thing I noticed about Legends, sometimes it could be useful to change their size / font type. As for example, we have in the case of the PlotText() method.
The "fontName", "fontSize", "bold" inputs could be also very useful for the Legend() method. What do you think, when we increase/decrease font size in a legend, should the legend markers follow these size changes too? I guess it would look nicer...
from scottplot.
A review of fonts for the title, axis labels, legend, and PlotText() is a good idea! Some of these features are implemented and some aren't, but a review of each of these methods to fill-in the missing features and ensure consistency would be an improvement for sure. I started an issue devoted to this topic #61
Regarding the marker size in the legend, I think it should reflect the marker size in the plot itself. Scatter plots could code plot groups by marker size, so since that may be its own metric let's stick to drawing it "actual size" in the legend.
from scottplot.
Regarding the marker size in the legend, I think it should reflect the marker size in the plot itself. Scatter plots could code plot groups by marker size, so since that may be its own metric let's stick to drawing it "actual size" in the legend.
This also makes me think we should probably should draw the lines in the legend as their actual size, since lineWidth might be used to separate groups of data... @Padanian do you want to make this change?
from scottplot.
from scottplot.
from scottplot.
It'll be awful. Been there, done that. That's why I set it to fixed linewidth.
I also think that line width in Legend does not need to match the plotted line width. Same applies to symbol/marker size. However, if we increase the font size (option will be in a later release) in the Legend, the marker/line symbols might become unproportionally small compared to it. Should the marker/line symbol size be scaled with the Legend font size? What do you think?
Actually the visibility of the Legend marker next to the text in the recent version also feels a little bit small, difficult to see the colored dots front of the Legend text lines...
from scottplot.
Marker size to reflect legend font size is ready to request pull, but you already got a pull request ahead. Please pull it before this or delete it.
from scottplot.
Just pulled @Padanian's branch into the master (#60). I called the argument "lineStyle" to be consistent with matplotlib's naming convention. I also added an example to the cookbook:
https://github.com/swharden/ScottPlot/tree/master/cookbook#custom-linestyles
Thanks @Padanian!
from scottplot.
Hi, I used this:
formsPlot1.Plot.AddCircle(x: midpoint.X, y: midpoint.Y, radius: radius, color: Color.Gray, lineWidth: 1, lineStyle: ScottPlot.LineStyle.Dash);
But the line draws solid.
from scottplot.
Related Issues (20)
- Signal: do not throw exception for size zero array
- Signal and Scatter: Improve render index naming consistency HOT 1
- Scatter: Inaccurate point nearest to the cursor HOT 1
- In Shared Axes while zooming Y Axis, only Y1 scale is updating for all the graphs but Y2 scale is not updating HOT 8
- Problem updating heatmaps when buffer changes HOT 2
- Adding Signal Data to a Graph in ScottPlot HOT 3
- Plot: Create `Clear<T>()` as an alias for `Remove<T>()` HOT 3
- Plot: Manually calling `Axes.AutoScale()` throws exception on empty plots HOT 1
- Heatmap: Left edge does not start at zero HOT 4
- SignalXY: Add `GetPointNearestX`
- Ticks: `EvenlySpacedMinorTickGenerator` unexpected behavior
- Draggable line on DateTime axis has unexpected snapping behavior HOT 2
- Controls: Prevent axis-specific middle-click-drag-zoom on empty axes
- SignalXY: Add support for `MaximumMarkerSize` like Signal has HOT 1
- SignalXY: last point sometimes does not get rendered
- NumericOperations: zooming too far into DateTime axes throws exception HOT 9
- Simplify process of using manual ticks
- ScottPlot 5 anti-aliasing HOT 8
- Need to set the fixed width for all the graphs irrespective of the Y1 & Y2 axis HOT 10
- Datetime on X axis in not displaying 24 hour format HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scottplot.