Code Monkey home page Code Monkey logo

plplotnet's Introduction

PLplot bindings for .NET Standard 2.0

Build status

PLplot is a cross-platform software package for creating scientific plots whose (UTF-8) plot symbols and text are limited in practice only by what Unicode-aware system fonts are installed on a user's computer.

The PLplot core library can be used to create standard x-y plots, semi-log plots, log-log plots, contour plots, 3D surface plots, mesh plots, bar charts and pie charts. Multiple graphs (of the same or different sizes) may be placed on a single page, and multiple pages are allowed for those device formats that support them.

Supported operating systems: Linux, MacOS, Windows

Output File Formats: PDF, PNG, JPEG, PostScript

.NET Standard 2.0 bindings

This package provides a complete, but unofficial, .NET binding for PLplot.

Documentation is available at https://surban.github.io/PLplotNet.

Obtain the NuGet package from https://www.nuget.org/packages/PLplot.

Usage

Create a PLPlot.PLStream object and call its instance methods.

See the examples in the Samples folder for more information.

plplotnet's People

Contributors

cvizzini avatar surban 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

Watchers

 avatar  avatar  avatar  avatar  avatar

plplotnet's Issues

Signed version

Hi, Would it be possible for you to create a signed version of your NuGet Package

mac: C# System.DllNotFoundException has been thrown

Hi, Im using Visual Studio Community 2017 Edition.
I have installed the PLPlot from brew.
All libraries have been added to the Cellar and system paths.

When running the example code for C# the following error happens:

System.DllNotFoundException has been thrown plplot

Line:
// create PLplot object
PLStream pl = new PLStream();

I have on my bash profile:
export LD_LIBRARY_PATH="/usr/local/Cellar/plplot/5.14.0_1/lib"

Any ideas what can be missing?

Thank you.

Usage in .NET Core console applications

The PLStream constructor throws an exception when called from a .NET Core 3.0 console application.

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'PLplot.Native' threw an exception.
Source=PLplotNet
StackTrace:
at PLplot.Native.mkstrm(Int32& p_strm)
at PLplot.PLStream..ctor() in C:...\PLStream.cs:line 24
at SineWaves.Program.Main(String[] args) in C:...\Program.cs:line 56

Inner Exception 1:
InvalidOperationException: Cannot find support PLplot support files in System.String[].

If called from a .NET Core 2.0 console application it works fine. I tested with the SineWaves console application from the c# samples.

C# example

I see two F# examples, any chance there are any C# examples.

C# 3D XYZ surface plot of a 2D array, and a possible issue

Hey,
I'm trying to make a surface plot of a 2D array, where its indexes would be the x and y axes and the values of the array would be z = f ( x, y ), but I'm failing miserably, even with the documentation, and examples on PLplot site written in C++.

How hard would it be to create a plot like this and what do I need?

I was trying to tinker around with plot3d method and I've checked out your C# example - I can set up the XYZ environment, but I can't create the plot itself:
sinewaves

Exiting my program causes this error to show up in my VS:
*** PLPLOT ERROR, ABORTING OPERATION *** plot3dcl: Bad option, aborting operation

Here's "my" code so far:

`var pl = new PLStream();

         //use SVG backend and write to SineWaves.svg in current directory

            pl.sdev("pngcairo");
            pl.sfnam("SineWaves.png");

        // use white background with black foreground
        pl.spal0("cmap0_alternate.pal");

        // Initialize plplot
        pl.init();

        double[] xIndexes, yIndexes;
        xIndexes = new double[temp.width];
        yIndexes = new double[temp.height];
        for (int i = 0; i < temp.width; i++)
            xIndexes[i] = i;
        for (int i = 0; i < temp.height; i++)
            yIndexes[i] = i;
        //Mesh opt = new Mesh();
        double[,] CDF = new double[surface.width, surface.height];
        for (int i = 0; i < surface.width; i++)
            for (int j = 0; j < surface.height; j++)
                CDF[i, j] = CumulativeDistributionFunction[i, j].result;//This is the array I'm trying to make a plot of

        Mesh opt = new Mesh(); // line with possible issue

        pl.adv(0);
        pl.col0(1);
        pl.vpor(0.0, 1.0, 0.0, 0.9);
        pl.wind(-1.0, 1.0, -1.0, 1.0);

        pl.w3d(1.0, 1.0, 1.0, 0, surface.width, 0, surface.height, 0, 1,60, 30);
        pl.box3("bnstu", "x axis", 0.0, 0, "bnstu", "y axis", 0.0, 0, "bcdmnstuv", "z axis", 0.0, 4);

        pl.col0(2);

        pl.scmap1n(256);

        pl.plot3d(xIndexes, yIndexes, CDF, opt, true); //line with possible issue
        pl.col0(3);
        pl.mtex("t", 1.0, 0.5, 0.5, "Title");
        // end page (writes output to disk)
        pl.eop();

        // output version
        pl.gver(out var verText);
        Console.WriteLine("PLplot version " + verText);`

Now about the possible issue - in the C and C++ implementations of example 11 that I've looked at (http://plplot.org/examples.php?demo=11&lbind=C%2B%2B), the plot3d method takes the opt argument as an int:
static const int opt[]; ... pls->plot3d( x, y, z, XPTS, YPTS, **opt[k]** | MAG_COLOR, true );

While in C# plot3d takes opt argument as a Mesh:
public void plot3d(double[] x, double[] y, double[,] z, Mesh opt, bool side);

As a result I have no idea what am I supposed to pass there, not to mention that I can't find the definitions of DRAW_LINEX, DRAW_LINEY and DRAW_LINEXY, or what they are anyway. Is opt supposed to be a Mesh?

So in the end - what am I doing wrong, what do I need to do to make a 3D plot of a 2D array, and could you maybe translate the example 11 to C#?

Error when running on MacOS

Hello,

I'm trying to use PLplotNet on the Mac using Visual Studio for Mac. I've installed PLPlot on my system and downloaded PLplotNet via NuGet.

When I run the app, I get the following exception:

DllNotFoundException
API-MS-WIN-CRT-ENVIRONMENT-L1-1-0.DLL
at (wrapper managed-to-native) PLplot.Native:_putenv_s (string,string)
at PLplot.Native..cctor () [0x00049] in <839be5c188a24e59a7156a92b7df2f7b>:0

I've tried running the same project in Windows and it works just fine. So obviously this is something specific to running in Mono.

Would you have any thoughts on how I might work around this?

Save to memory stream

It looks like all the saving is handled in the library itself.

I'd rather save to a memory stream as I need to do extra processing on the image, and have no reason to save to disk. Is there a way to do this?

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.