Skip to content

How to create polar plots with Csharp  #427

Description

@jackthomas818

Is there any support for producing polar plots with C# using Plotly.NET? The documentation only has F# code.

Activity

  1. kMutagene commented on Oct 25, 2023

    @kMutagene
    Collaborator

    Hi @jackthomas818, yes there are multiple ways:

    • F# is part of .NET, same as C#. You can use F# libraries from C#, meaning you can translate the samples.

    • There is Plotly.NET.CSharp (see also https://plotly.net/#Installation), a more idiomatic C# API. It is written in C# but less feature complete than the core F# API. It has polar chart creation but less styling options:

      using Plotly.NET.CSharp;
      Chart.PointPolar<int, int, string>(
            theta: new[] { 0, 45, 90, 180, 270, 360 },
            r: new[] { 1, 2, 3, 4, 5, 6 }
        );

    image

  2. jackthomas818 commented on Oct 25, 2023

    @jackthomas818
    Author

    I've got the basic polar plot displaying. Is it possible to rotate the polar plot clockwise 90 degrees so that the 0 degree is on the bottom of chart?

  3. kMutagene commented on Oct 26, 2023

    @kMutagene
    Collaborator

    yes it is, the respective member is however on the AngularAxis object which is not wrapped in the CSharp lib. You can fallback on mixing both APIs, but will have to prefix the calls:

    using Plotly.NET.CSharp;
    using Plotly.NET;
    using Plotly.NET.LayoutObjects;
    
    var c = 
        Plotly.NET.CSharp.Chart.PointPolar<int, int, string>(
            theta: new[] { 0, 45, 90, 180, 270, 360 },
            r: new[] { 1, 2, 3, 4, 5, 6 }
        );
    
    Plotly.NET.Chart.WithAngularAxis(
        AngularAxis.init<int, int, int, int, int, int>(Rotation: 270)
    ).Invoke(c)

    image

    I'll go ahead and close this, please use either the Github discussions tab or the discord for questions - issues are more intended for bugs and feature requests

  4. locked and limited conversation to collaborators on Nov 3, 2023
  5. converted this issue into a discussion #432 on Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions