Giter VIP home page Giter VIP logo

Comments (22)

swharden avatar swharden commented on May 18, 2024 1

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:

image

from scottplot.

Padanian avatar Padanian commented on May 18, 2024 1

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

swharden avatar swharden commented on May 18, 2024

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()

image

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

swharden avatar swharden commented on May 18, 2024

@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.

Padanian avatar Padanian commented on May 18, 2024

Yes, this one
immagine
Do I need to redefine dashes and spaces?

from scottplot.

swharden avatar swharden commented on May 18, 2024

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;

image

from scottplot.

swharden avatar swharden commented on May 18, 2024

... actually, maybe all our patterns should be custom? Maybe the dash values are some multiple of line width?

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

immagine

from scottplot.

swharden avatar swharden commented on May 18, 2024

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.

bukkideme avatar bukkideme commented on May 18, 2024

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.

swharden avatar swharden commented on May 18, 2024

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.

swharden avatar swharden commented on May 18, 2024

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.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

from scottplot.

bukkideme avatar bukkideme commented on May 18, 2024

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...
example1

from scottplot.

Padanian avatar Padanian commented on May 18, 2024

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.

swharden avatar swharden commented on May 18, 2024

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.

marc-frank avatar marc-frank commented on May 18, 2024

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)

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.