Пример #1
0
        private void Button_Click_Gnuplot(object sender, RoutedEventArgs e)
        {
            GnuPlot.Set("terminal png size 500, 300");
            GnuPlot.Set("output 'gnuplot.png'");
            //GnuPlot.Plot("sin(x) + 2");
            //GnuPlot.Close();
            //gnuplotImage.Source = null;
            //gnuplotImage.Source = new BitmapImage(new Uri("pack://siteoforigin:,,/gnuplot.png"));



            //GnuPlot.Set("terminal png size 400, 300");
            //GnuPlot.Set("output 'gnuplot.png'");
            double[] X = new double[] { -15, -15, -15, -15, -15, -14, -14, -14, -14 };
            double[] Y = new double[] { 11, 12, 13, 14, 15, -15, -14, -13, -12, -11 };
            double[] Z = new double[] { 20394, 15745, 11885, 8771, 6330, 8771, 12155, 16469, 21818 };
            //double[,] Y = new double[,]
            //{
            //    { 0,0,0,1,2,2,1,0,0,0},
            //            { 0,0,2,3,3,3,3,2,0,0},
            //            { 0,2,3,4,4,4,4,3,2,0},
            //            { 2,3,4,5,5,5,5,4,3,2},
            //            { 3,4,5,6,7,7,6,5,4,3},
            //            { 3,4,5,6,7,7,6,5,4,3},
            //            { 2,3,4,5,5,5,5,4,3,2},
            //            { 0,2,3,4,4,4,4,3,2,0},
            //            { 0,0,2,3,3,3,3,2,0,0},
            //            { 0,0,0,1,2,2,1,0,0,0}
            //};
            //GnuPlot.Set("dgrid3d 50,50,2");
            //GnuPlot.Set("7,7,7");
            GnuPlot.Set("pm3d");
            GnuPlot.Set("dgrid3d");
            //GnuPlot.Set("contour");
            //GnuPlot.Set("map");
            //GnuPlot.Set("dgrid3d");
            //GnuPlot.Set("cntrparam levels 20", "isosamples 100");
            GnuPlot.Set("view map");
            //GnuPlot.Set("pm3d interpolate 10,10");

            GnuPlot.SPlot(X, Y, Z);
            GnuPlot.Set("output");

            GnuPlot.Close();

            while (true)
            {
                if (File.Exists(AppContext.BaseDirectory + "gnuplot.png") && new FileInfo(AppContext.BaseDirectory + "gnuplot.png").Length > 0)
                {
                    break;
                }
                Thread.Sleep(100);
            }
            GnuPlot.KillProcess();

            gnuplotImage.Source = null;
            gnuplotImage.Source = new BitmapImage(new Uri("file://" + AppContext.BaseDirectory + "gnuplot.png"));
        }
Пример #2
0
        public static void PlotInitialGeometry(IAssembly assembly)
        {
            GnuPlot.Set("terminal png size 1920, 1080");
            GnuPlot.Set("output 'gnuplot.png'");
            GnuPlot.HoldOn();
            GnuPlot.Set("size ratio -1");
            GnuPlot.Unset("key");
            double[]          X, Y;
            List <StoredPlot> storedPlots = new List <StoredPlot>();

            //List<double> X = new List<double>();
            //List<double> Y = new List<double>();
            foreach (var element in assembly.ElementsAssembly)
            {
                int numberOfNodes = element.Value.Nodes.Count;
                for (int i = 1; i <= numberOfNodes; i++)
                {
                    if (i != numberOfNodes)
                    {
                        //X.Add(element.Value.Nodes[i].XCoordinate);
                        //X.Add(element.Value.Nodes[i+1].XCoordinate);
                        //Y.Add(element.Value.Nodes[i].YCoordinate);
                        //Y.Add(element.Value.Nodes[i + 1].YCoordinate);
                        X = new double[] { element.Value.Nodes[i].XCoordinate, element.Value.Nodes[i + 1].XCoordinate };
                        Y = new double[] { element.Value.Nodes[i].YCoordinate, element.Value.Nodes[i + 1].YCoordinate };
                    }
                    else
                    {
                        //X.Add(element.Value.Nodes[i].XCoordinate);
                        //X.Add(element.Value.Nodes[ 1].XCoordinate);
                        //Y.Add(element.Value.Nodes[i].YCoordinate);
                        //Y.Add(element.Value.Nodes[ 1].YCoordinate);
                        X = new double[] { element.Value.Nodes[i].XCoordinate, element.Value.Nodes[1].XCoordinate };
                        Y = new double[] { element.Value.Nodes[i].YCoordinate, element.Value.Nodes[1].YCoordinate };
                    }

                    if (element.Value is ContactNtN2D)
                    {
                        storedPlots.Add(new StoredPlot(X, Y, "with linespoints pt " + (int)PointStyles.SolidCircle + " lt rgb \"red\""));
                        //GnuPlot.Plot(X, Y, "with linespoints pt " + (int)PointStyles.SolidCircle + " lt rgb \"blue\"");
                    }
                    else if (element.Value is ContactNtS2D)
                    {
                        storedPlots.Add(new StoredPlot(X, Y, "with linespoints pt " + (int)PointStyles.SolidCircle + " lt rgb \"red\""));
                    }
                    else
                    {
                        storedPlots.Add(new StoredPlot(X, Y, "with linespoints pt " + (int)PointStyles.SolidCircle + " lt rgb \"blue\""));
                        //GnuPlot.Plot(X, Y, "with linespoints pt " + (int)PointStyles.SolidCircle + " lt rgb \"blue\"");
                    }
                }
            }
            GnuPlot.Plot(storedPlots);
            GnuPlot.HoldOff();
            //GnuPlot.Close();
            //GnuPlot.KillProcess();
        }
Пример #3
0
 public static void PlotHeatMap(List <HeatMapData> plots)
 {
     GnuPlot.HoldOn();
     GnuPlot.Set("cbrange[0:7.0]");
     GnuPlot.Set("palette defined(0 \"blue\", 0.33\"green\", 0.67\"yellow\", 1 \"red\")");
     GnuPlot.Set("pm3d");
     GnuPlot.Set("dgrid3d");
     GnuPlot.Set("view map");
     foreach (var plot in plots)
     {
         GnuPlot.SPlot(plot.Xcoordinates, plot.Ycoordinates, plot.Temperatures);
     }
 }