I am trying to plot a csv file using d3j. I can get a simple scatter plot up and running with no problem. This is what I am having trouble with:
Assume that the columns are x,y,z. I want the user to be able to plot any combination (x vs y, x vs z, y vs z, and so on) (just like the http://www.gapminder.org/world/ where you can select the axis amongst many variables).
Could any one point me to an example where I can learn this?
Thanks
Related
I'm new to Julia and I used MNIST handwritten digit train data to get multiple images in matrix with size 28 x 28. Let's assume I store them in array img[i] with length n(n is dynamic). I want to show Images in one window such that every image has its own specific label under it.
I tried to search and read documents, currently I use hcat(images_window, img[i]) for all images and plot(images_window) and annotate some text label for each image in specific coordinates. This way is not a good practice and n is not configurable either.
I expect Julia have something like dynamic layout for its plots and I can show Image in each subplot and show them in a window with something like this:
plt = plot()
for (i, subplot) in enumerate(plot)
plot!(plt, subplot, layout(i))
end
display(plt)
You didn't mention which plotting library you are using but from the basic syntax I'm vaguely guessing that you might be asking bout Plots.jl.
In Plots, plotting multiple subplots on one figure in principle works like this:
using Plots
p1 = plot(rand(5))
p2 = plot(rand(5))
plot(p1, p2)
i.e., you call plot with multiple arguments which themselves are plots. You can then additionally specify a layout kwarg, which in its simplest form takes a tuple of (nrows, ncols) and places the subplots in a grid with the specified number of rows and columns.
As an example, here's three plots next to each other:
plot(plot.([rand(5) for _ ∈ 1:3])..., layout = (1, 3))
I've written a program which reads measurements from an impedance analyzer as it sweeps over a range of frequencies or voltages, saves the data to a text file, and also creates a scatter plot. In one type of measurement, I obtain x and y values for complex impedance, neither of which are the independent parameter. Now when plotting this graph, it appears that it simply puts each x value to the right of the previous one at regular spacings resulting in x axis labels looking like, from left to right, [45000, 43000, 40000,... etc.].
I've tried forcing the x-axis to start from zero which did not change anything and haven't been able to find much else on this. Is there a way to make sure the plot reflects the actual x values of each point?
Here's my current method of creating the chart,which pulls the data from the already created table:
For Each row In table.Rows
Chart1.Series("series1").Points.AddXY(row(0), row(1))
Next
I want to plot only one simple set of data. For example, my plot command could be :
x = (1:10);
y = ones[1,10];
plot(x,y);
In fact, the y data set could have been generated by a previous code, depending on several parameters. I want to print the name of every parameters and there values outside the graph, at the right of it, as if it were a legend. My problem is that I have several parameters to print, but only one set of data.
I tried to do this by the text or legend functions, but it never fit completly my needs.
Could you help me please ?
I think this code should help you out. Its probably easiest to split your figure into two axes, the right one just to hold text:
x = rand(1,10);
y = rand(1,10);
figure % makes your figure
axes('Position', [0.05,0.05,0.45,.9]) % makes axes on left side of your figure
scatter(x,y)
axes('Position', [0.55,0,1,1],'ytick',[],'xtick',[]) %make axes on left side of your figure, turns of ticks
text(0.05,0.85,{'Parameter 1: blah blah';'Parameter 2: bloop bloop';'Parameter 3: ....'},'Interpreter','Latex')
Play around with the numbers in the brackets to resize things as you like.
Let's say I have a list of values and I have already chunked them into groups to make a histogram.
Since Excel doesn't have histograms, I made a bar plot using the groups I developed. Specifically, I have the frequencies 2 6 12 10 2 and it produces the bar plot you see below.
Next, I want to add a normal distribution (line plot) with a mean of 0.136 and standard deviation of 0.497 on top of this histogram. How can I do this in excel? I need the axis to line up such that it takes up the width of the bar plot. Otherwise, you get something like I've attached.
But...the normal should be overlayed on the bar plot. How can I get this effect?
There are two main part to this answer:
First, I reverse-engineered the grouped data to come up with an appropriate mean and standard deviation on this scale.
Second, I employed some chart trickery to make the normal distribution curve look right when superimposed on the column chart. I used Excel 2007 for this; hopefully you have the same options available in your version.
Part 1: Reverse-Engineer
The column B formulae are:
Last Point =MAX(A2:A6)
Mean =SUMPRODUCT(B2:B6,A2:A6)/SUM(B2:B6)
E(x^2f) =SUMPRODUCT(A2:A6^2,B2:B6)
E(xf)^2 =SUMPRODUCT(A2:A6,B2:B6)^2
E(f) =SUM(B2:B6)
Variance =B10-B11/B12
StDev =SQRT(B13/(B12-1))
Part 2: Chart Trickery
Data table:
Column D is just an incremental counter. This will be the number of data points in the normal distribution curve.
E2 =D2/$B$8 etc.
F2 =NORMDIST(E2,$B$9,$B$14,FALSE) etc.
Chart:
Now, add Columns E:F to the chart. You will need to massage a few things:
Change the series to be an X-Y plot. This might require some editing of the chart series to force a single series to use your desired X and Y values.
Change the series to use the secondary axes (both X and Y).
Change the secondary X-axis range to 0.5-5.5 (i.e., 0.5 on either side of the column chart category values). This will effectively align the primary and secondary X-axes.
Change the secondary Y-axis range to 0-1
Format the X-Y series appearance to taste (I suggest removing value markers).
The result so far:
Lastly, you can remove the tick marks and labels on the secondary axes to clean up the look.
Postscript: Thanks to John Peltier for innumerable charting inspirations over the years.
I have some data from model in Femlab. Because I would like to work on the results more, I would like to use Octave / Gnuplot as well to visualize the computed data. I have exported the data from Femlab into a txt file in form "x y z value" (4 columns). Everything unsorted - than can I do. But how to get this into gnuplot? I can choose one of the variables to fix it(let's be it x) and plot the rest y,z and value by splot. But, I have thousand and thousand of numbers and this is not possible, than Femlab doesn't keep the variables fixed (so you sort it along x and find out that there are no two x values the same).
I know about Femlab / Matlab interface, but unfortunately I havent Matlab.
Thank you in advance!
Have you tried scilab? It is a matlab clone like octave and seems to support some FEM stuff: http://wiki.scilab.org/Finite%20Elements%20in%20Scilab.
See also http://www.utc.fr/lrm/giens05/CDROM/CDROM/lo01.pdf a paper where they interface Scilab and OpenFEM.