How can Newton's basin of attraction be created from a data file?
I got 10000 points in the range -2, 2 and their zeros for complex function z^3-1. I'd like to plot them with three different colors to create basin of convergence.
Data I've obtained from my program is available here. The format is like this:
(-0.422468,1.36075) (-0.5,0.866025)
(1.19376,1.1324) (1,-6.76273e-19)
...
First two numbers in "( )" are complex start points, the second two are the zero that it converges to. Zeros are exact to the level of e-10, I can easily change it to e-16.
From what I understand, I would try something like:
plot 'yourdata.dat' using 1:2:(arg($3+$4*{0,1})) '(%lf,%lf) (%lf,%lf)' palette
The string '(%lf,%lf) (%lf,%lf)' is the format of your data, so that gnuplot can read it as a file of four columns. Then, you can select the columns to be plotted with using 1:2:(arg(...)); in this case, the x-axis is the real part of the starting points (column 1), and the y-axis is its imaginary part (column 2). The third part of using, arg($3+$4*{0,1}), and the option palette are used to chose the color depending on the phase of the complex zero (columns $3 and $4).
Related
Below is an Excel Chart for the data shown in column A (x-coordinates--dates) and column B (y-coordinates--test results). There's no problem with the column B data. But note that the horizontal axis shows quite a few more dates than are contained in column A.
Is there any way to have only the actual x-coordinates shown on the horizontal axis with a scale that matches those values?
I kind of get it. Excel deliberately scales the horizontal axis to match as best it can the data in column A. But I don't want that. Beneath each "corner" point of the graph, I'd like to see the date that is associated with the test result in column B.
In other words, there is clearly a point with y-coordinate 154.5. I'd like to see 2/13/2018 directly below that point since that is the data in row 5. Note that the x-axis contains the "correct" date for the first plotted point: (2/9/2017, 70). But for the point with y-coordinate 80, it looks as if that test result occurred on 6/9/2017 rather than 6/16/2018.
So I'd like the graph to appear as shown in the second image, which likely would be impossible because of the "crowding" of x-coordinate values at the right-hand end, but just displaying whichever of the three dates would fit would be good enough, as would just showing one of the two dates in other "crowded" areas. That is to say that something like the third image would be fine.
I suppose I could write VBA code to make it happen, but I'd prefer that Excel do it.
(What crosses my mind is, "Are exact dates really this important?" And the jury is still out on this point. There are arguments both ways. I guess a hung jury goes to the judge, Excel.)
By inserting the points to be plotted into two arrays, datesArr and scaledArr, and putting those values into columns A and B (see worksheet) and in code saying ...
Set ch = ActiveChart
Set s = ch.SeriesCollection
s(1).Values = scaledArray
s(1).XValues = datesArr
... I got exactly what I wanted. Now granted that's not exactly built-in, but we're programmers, yes? And this was downright easy. Well, once I learned a few tricks, especially being able to set angle of dates to 45 degrees.
You need to plot two sets of data, the actual values, and a set of zeros, then smoke and mirrors make it work.
Data below left, make a line chart (top left chart). Add data labels to the second series; I colored the labels orange to match the points, for clarity in this description. Default labels show Y values, which are all zero (top right). Format the data labels to show category values (i.e., dates), below the points, rotated upwards (bottom left). Format format format (bottom right). Axis labels: none. Format second series with medium gray lines and medium gray cross markers. Drag bottom of plot area upwards to make room for the date labels. Hide legend.
My problem is as follows:
The user inputs two numbers between 2 and 25, these numbers are used to create a grid. Every point on the grid has (x,y) coordinates. Based on the amount of points the user chose, my excel sheet is filled up with up to 25x25 (x,y) coordinates.
Example: A 6x7 grid is chosen by the user, the table is filled with 42 (x,y) coordinates and all other values in the table are set to "".
Now I want to use a scatterplot with lines connecting each array to plot the data.
Problem 1: If I only select the 6x7 part of the table that has values in it and create the scatterplot the result is correct. Until the user specifies a different grid, for example 8x9, then the graph is obviously missing two rows and two columns of input data.
Problem 2: If I select the entire 25x25 part of the table, including all the "" values, the graph axes get messed up. The y-axis works properly, but the x-axis shows sequential values (0-7) instead of the x-coordinates.
Problem 3: If I replace all the "" values in the table to 0 or NaN and plot the entire table the axes are correct, but the lines between the scatter data get messed up.
Question:
Is there a way to automatically change the input data for the plot, or is there a way to correctly display the values on the x-axis if I select all the data?
Not sure this will work in your case, but it's worth a try, especially since no one's addressed your post in 3+ hours. I've had success with this approach: 1) charting the largest data set, 2) copying the resulting chart, and 3) trimming the data it draws from to produce all smaller data sets.
To get this to work takes a lot of thought in laying out that largest data set so that all the other plots follow as needed. To illustrate, I've somewhat mimicked your data and in the animated gif I show largest data set, plus 2 others produced by copying it. Then I demonstrate how to make the second one, including the rescaling required to make all plots scaled equally. Notice that I've arranged things so that only one set of x-values feeds all the series. If you can do this, it makes working with the Excel's interface much easier.
After wrestling with it all night I came to the following solution:
Instead of setting all the empty cells to "" or zero the cells should be be set to #N/A (not available). The graph properly ignores the #N/A cells exactly like I want it to and updates when values are entered into them.
I have managed to plot two different data sets on the same axis however, I'm also looking to plotting another line showing their average.
The main problem is that both data sets have different X (time) values so it's not possible to add an average column at the end and plot that. (See the highlighted row 22 for example, corresponding Time values are different)
Is there any way I can plot an average of two plots on the same axis?
One idea that might work is to place the values of both series, one above the other in two new columns, sort this new data according to time, smooth it, then plot the smoothed combined data. Alternatively, you could do the smoothing by simply plotting the new sorted series, adding a moving average trendline to it, then change the formatting of the new series so that it is no longer visible (but the trendline is). Something like this:
In the above picture, series 3 is the plot of the sorted aggregate data of series 1 and 2. If you change the formatting of series 3 so that there is no line, you get something like this:
For my relatively small mock data sets, the results are admittedly poor (it was based on just 25 data points in each series), but if you have a large amount of closely spaced data, and you play around with the moving average window size, you might get something acceptable. If not, you should probably just interpolate both datasets to obtain two consistent time series.
I have two columns of data - first is fractions (goes on x-axis), second is integers (goes on y).
Is there a way to plot one against the other in a histogram type manner so it looks like a spectrum?
Use the "scatter plot" tool. It is also called a "scatter chart" tool. Once you have your chart in place, you can add a trend line to determine the formula for the relationship between x and y values. You will be able to find the formula in terms of y = mx+b. You can also determine the r squared value which will be important in the interpretation of the relationship. There are several options for scatter charts that might lead you off course, so experiment with the tool a bit to discover the correct options for your situation.
I have a scatterplot with values that range from 2 to -2. The catch is that 1 is the "zero-point". In other words the minimum positive value is 1.01 and the minimum negative value is -1.01. How can I edit the axis of the graph so that 0 is replaced with 1.
If you have a version of Excel later than 2007 I'd suggest splitting the positives and negatives into separate series and plotting one on a secondary axis (not that I know whether or not that would work!), but with 2007 I have not been able to place one vertical axis above the horizontal and another below. Instead the best I could manage was to use two separate charts:
by again splitting up the series, careful positioning and judicious use of a text box for 0.
At least this way you are not constrained by the outer limits.
Based on some very specific conditions you can print the zero-point as 1 using a custom number format: You have to set the axis options to be fixed at -2 (minimum) and 2 (maximum) with a major unit of 2 as well. This ensure that you only have the three values -2, 0 and 2 on the vertical/y-axis. Why is this important? Well, custom number formats can easily distinguish between positive/negative and zero values which is exactly what you have when you have -2, 0 and 2.
Here's a visual of the input/output:
The custom number format is set to 2;-2;1, thereby formatting all positive numbers to 2, all negative numbers to -2 and zero to 1.
If all you want is to replace the axis label "0" with "1" (as in the answer by Werner), then you can use the following (similar to this):
Add X and Y values for a dummy series, with 3 points. If the minimum value in your X-axis is xm, your points are (xm, -2), (xm, 0), (xm, 2).
Add cells with the 3 labels that you will use for the dummy series: "-2", "1", "2".
Go to the chart, and remove the tick labels of the Y-axis.
Add a series with the 3 dummy data points.
Add the labels to the data points. You can use references to the cells of item 2, or enter explicit labels. Entering each label (either a reference or an explicit label) is tedious when you have many data points. Check this, and in particular Rob Bovey´s add-in. It is excellent.
Format the dummy series so it is visually ok (e.g., small, hairline crosses, no line).
You can use variations on this. For instance, you can add extra points to your dummy series, with corresponding labels. Gridlines would match the dummy series.
But I think this is not appropriate, as the locations of your data points will be inconsistent with the scales.
What is appropriate is having an interrupted axis, where the interval (-1,1) is eliminated.
The answer by pnuts aims at that.
I propose something different, with the advantage of using only one chart:
Create a column where you add 2, only to negative Y-values. Use that column as your new Y-values.
Use the same trick as above, with your dummy series now being (xm, 0), (xm, 1), (xm, 2), and the labels the same as above.
You can use additional points in your dummy series.
You can use this technique to create an arbitrary number of axis interruptions. The formula for the "fake" Y-values would be more complicated, with IFs to detect the interval corresponding to each point, and suitable linear transformations to account for the change in scale for each interval (assuming linear scales; no mixing linear-log). But that is all.
PS: see also the links below. I still think my alternative is better.
http://peltiertech.com/broken-y-axis-in-excel-chart/
http://ksrowell.com/blog-visualizing-data/2013/08/12/how-to-simulate-a-broken-axis-value-axis/
http://www.tushar-mehta.com/excel/newsgroups/broken_y_axis/tutorial/index.html#Rescale%20and%20hide%20the%20y-axis