I am trying to use paraview to plot a xy plot. The plot I want is just a linear relationship between x and y. So I import my data file (data.csv) into paraview. My data is shown below:
X Y
0 0
1 1
2 6
3 8
4 15
Then I set the delimiter to " ". After that I can see the data is sorted in x and y column. But I do not find a option to let paraview to plot the data. Any help? Thank you.
Here is a screenshort of my interface:
Add a Plot Data filter while you have data.csv selected and click Apply. a Line Chart View will open up, but it won't show anything. In the Properties panel, scroll down to the Series Parameters subsection. Click on the checkbox to the left of the variable "Y". To put "X" on the x axis, uncheck the Use Index for XAxis checkbutton and set the X Array Name to "X".
Related
I need to hide 4 lines from the legend. I'm using shadedErrorBar so I have 3 line for a sigle group (mean, upper edge of standard deviation and bottom edge) and if i use the classic code legend('line1','line2,'...) I'll have 3 label. I want in the legend only the mean for each group.
I have 2 groups.
shadedErrorBar(x,y1,e1);
shadedErrorBar(x,y2,e2);
y1 and y2 are my means, while e1 and e2 standard deviations.
I think I should use IconDisplayStyle but I don't understand how. I read this http://it.mathworks.com/help/matlab/creating_plots/controlling-legends.html but is like hide a plot to hide a line. With shadedErrorBar I have a graph with 3 plot on it for each group.
When you create the legend, you can specify only the plot objects that you would like to create legend entries for. The output of shadedErrorBars is a struct containing all of the plot objects so you can use these to grab the patch objects and create legend entries for only those.
h1 = shadedErrorBar(linspace(1,10), linspace(1,10), linspace(0,1));
hold on
h2 = shadedErrorBar(linspace(1,10), linspace(1,20), linspace(1,0));
legend([h1.patch, h2.patch], {'Item1', 'Item2'})
I'm plotting a control system and I need to prove that the steady state error from MATLAB coincides with my calculations.
My calculations have given me 0.000833333, and on the plot, the data-tip markers have very little precision (no decimal points at the location I selected).
However I can right-click the marker and select Export cursor data to workspace...
This gives me the position location of X=98.0037, Y=98.0028
That gives me an error of 0.0009, so it's not quite the 0.00083333 from calculations. I know this is correct however, I just would like to know how to increase the precision of the variables/data points from plot past 4 decimal places if possible.
There are many different routes to get more precisions from these data tip cursors:
1) Export manually:
As you mentioned in your question, right click on the datatip then select Export cursor data to workspace.... Let's assume you export that in the default variable cursor_info, you then get a structure with 3 fields:
cursor_info =
Target: 492.0040
Position: [7.3593e+05 10.6353]
DataIndex: 7
Target is the handle of the line object to which the cursor was snapped
Position is a 1x2 vector giving the x and y coordinates of the selected data points (it will have a third value if the z coordinates are defined)
DataIndex is the index of the selected data point coordinates in the array that was used to plot the line. So you could also ask for :
>> x(7) %// or "x(cursor_info.DataIndex)" would be the same
ans =
7.3593e+05
>> y(7)
ans =
11.3200
Now by default the display of values in the console is limited to a few digits, but the number in the variable has more precision. 2 ways to display more precision:
First method is to type format long in the console. After that all your numeric output in the console will be with 15 digits:
>> cursor_info.Position
ans =
1.0e+05 *
7.359289702215524 0.000106353183026
Second method is to force the precision you desire by using a format specifier and sprintf or fprintf:
>> fprintf('x=%15.15d y=%g \n',cursor_info.Position)
x=7.359289702215524e+05 y=10.6353
2) Export programatically
Alternatively to the manual export of the cursor_info data, you can call that with code:
dcm = datacursormode(gcf) ;
cursor_info = dcm.getCursorInfo ;
You then get the same cursor_info variable than if you exported it manually. Displaying the values can be done the same way than above.
3) Direct display (at the wanted precision).
You can also achieve a full customization of what the data tip will display, not only the position but also some calculated or converted values. Right click on the data tip and select Edit text update function. This will open an editor window with the current code for the data tip, which basically query the data tip position and create a cell array of text to be displayed. Modify this function to your needs then save it somewhere you can retrieve it.
For an example with the data I was using, I display the x and y coordinates with different precision, then a calculation based on the 2 values, and I also convert the x coordinates to the date representation.
function output_txt = myModifiedDatatip(obj,event_obj)
pos = get(event_obj,'Position');
output_txt = {['X: ',num2str(pos(1),12)],... %// default code, only the output precision is changed
['Y: ',num2str(pos(2),8)]};
%// add all the informations you want to calculate and display directly here:
output_txt{end+1} = ['error (y-x): ',sprintf('%16f', pos(2)-pos(1))]; %// difference between x and x
output_txt{end+1} = ['Date: ', datestr(pos(1))]; %// display the date/time
This example will display a data tip like so:
After that, on any subsequent plot or figure, you can re-apply this data tip format by right clicking on a data tip, select text update function, then point to the data tip function you saved earlier.
I am trying to create a bar chart where my x axis shows only one data point, year of 2006, but for 3 different data related to 2006. I am doing the following, but I receive the
error of "X must be same length as Y."
Here is my code and I highly appreciate your help:
X=[2006] %year
% Create data for childhood disease cases
measles = [38556];
mumps = [20178];
chickenPox = [37140];
% Create a vertical bar chart using the bar function
figure;
bar(X, [measles' mumps' chickenPox'],'group');
% Set the axis limits
%axis([0 13 0 40000]);
% Add title and axis labels
title('Childhood diseases by month');
xlabel('Month');
ylabel('Cases (in thousands)');
% Add a legend
legend('Measles', 'Mumps', 'Chicken pox');
You are getting this error because X is only one element and you are using three different Y values.
I think this problem requires you to take a step back a bit. Why are you plotting all three against the same X value? If this worked as you specified, all three would be on top of each other.
Would it not be more informative to the viewer if the X-axis labeled each bar as measles, mumps or chickenPox?
Try:
bar([measles' mumps' chickenPox']);
set(gca,'XTickLabel',{'Measles','Mumps','Chicken Pox'});
Edit:
I see what you're after. You're almost correct. The problem is that since you only have one column of data, matlab assumes you DON'T want to create a group but just plot those 3 values against unique X values. So we need to trick it slightly by creating another data point.
% //Create two columns, one of them zeros
data = [[measles;mumps;chickenPox],[0;0;0]];
bar([X,X+1],data'); % //The 2007 entry will not be visible
This will create a group at 2006 and the 2007 entry will be zeros so you won't see it. You can then set your axes and such to be the same as the other charts.
I have a matrix of fft data over time, 8192 rows of data x 600 columns of time. The first column is a frequency label, the first row is shown below but doesn't actually exist in the data file, neither do the spaces, they are shown just for ease of reading.
Frequency, Sec1, Sec2, Sec3...Sec600
1e8, -95, -90, -92
1.1e8, -100, -101, -103
...
It is plotted in matlab with the following code (Apologies to other posters, I grabbed the wrong matlab code)
x is a matrix of 8192 rows by 600 columns, f is an array of frequency labels, FrameLength = 1, figN = 3
function [] = TimeFreq(x,f,FrameLength,figN)
[t,fftSize] = size(x);
t = (1:1:t) * FrameLength;
figure(figN);
mesh(f,t,x)
xlabel('Frequency, Hz')
ylabel('time, sec')
zlabel('Power, dBm')
title('Time-Freq Representation')
I cant quite figure out how to make it work in gnuplot. Here is a sample image of what it looks like in Matlab: http://imagebin.org/253633
To make this work in gnuplot, you'll want to take a look at the splot (for "surface plot") command. You can probably figure out quite a lot about it just by running the following commands in your terminal:
$ gnuplot
gnuplot> help splot
Specifically, you want to read the help page shown by running (after the above, when the prompt asks for a subtopic): datafile. That should tell you enough to get you started.
Also, the answers to this question might be helpful.
so here is the gnuplot command script that I ended up using. It has some additional elements in it that weren't in the original matlab plot but all the essentials are there.
set term png size 1900,1080
set datafile separator ","
set pm3d
# reverse our records so that time moves away from our perspective of the chart
set xrange[*:*] reverse
# hide parts of the chart that would make the 3d view look funny
set hidden3d
# slightly roate our perspective and compress the z axis
set view 45,75,,0.85
set palette defined (-120 "yellow", -70 "red", -30 "blue")
set grid x y z
set xlabel "time (secs)"
set ylabel "frequency"
set zlabel "dBm"
# plot all the data
set output waterfall.png
splot 'waterfall.csv' nonuniform matrix using 1:2:3 with pm3d lc palette
OK, I have searched for an answer to this for ages, so please don't give me minus points :)
I want to make a simple XY scatter graph in OpenOffice Calc, however when I have selected the X and Y columns and chosen the XY scatter, no data points show up in the graph.
My sheet has like 400 rows with the A column, X axis, containing numbers between 1 and 400, in order, and the B column, Y axis, with values between -2 and +2 not in order. This is driving me crazy!
I have made sure that the min. is not 0 but -5, so that cannot be it.
Anyone has an idea of what I'm doing wrong?
I had this problem -- Check the data you're using for the chart.
If you've done a cut-and-paste, you may have brought in some non-numeric characters.
First look at the numbers. They should automatically line up on the right side of the cell, unless you've changed the alignment.
Next, click a cell and look at the value displayed in the formula bar. Remove spaces or other non-numeric characters and hit enter.
Repeat for all cells in the data series.