Question

i have an equation of a curve that i need to draw like:

((X^z)-1)/z = y

does anyone know how i can draw this curve and save it as an image using python or .net?

Was it helpful?

Solution

A good library for 2d plots in Python is http://matplotlib.sourceforge.net/. The resulting plot can be saved straight from the plot dialog.

OTHER TIPS

Here's an example of drawing your curve in .NET/C#:

References:

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

Drawing Code:

const int imgSize = 500;
var bmp = new Bitmap(imgSize, imgSize);
using (var g = Graphics.FromImage(bmp))
{
    g.SmoothingMode = SmoothingMode.HighQuality;
    var points = new Point[imgSize];
    const int z = 10;
    g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);

    for (var x = 0; x < imgSize; x++)
    {
        var y = bmp.Height - (x^z-1)/z;
        points[x] = new Point(x, y);
    }

    g.DrawCurve(Pens.Black, points);
}

bmp.Save(@"C:\Users\your_name_here\Desktop\myCurve.png", ImageFormat.Png);

I made some assumption such as making Z a constant. Also the image size if fixed at 500 and the plotting only happens in the upper-right (positive/positive) location of the cartesian plane. But that's all stuff you can figure out. Note that Y needs to be adjusted since Windows plots 0,0 at the upper left of the screen: var y = bmp.Height - (x^z-1)/z;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top