I am looking for a command line that allows to draw a square in my plot in GrADS. Here is an example
I would like to get a command line which allows me to draw a square like the one that I show on my picture example.
I assume the boundaries of the square you want to draw are based on lat/lon coordinates, and the bottom left corner is at (4N, 74W) and the upper right corner is at (8N, 72W). The following script fragment should work, but you must draw the plot first in order to set up the scaling between world coordinates and X,Y location on the page.
'q w2xy -74 4'
xpos1=subwrd(result,3)
ypos1=subwrd(result,6)
'q w2xy -72 8'
xpos2=subwrd(result,3)
ypos2=subwrd(result,6)
'set line 2 1 6' '* a thick, red line
'draw rec 'xpos1' 'ypos1' 'xpos2' 'ypos2
This is what it looks like if you are working with GrADS interactively:
ga-> q w2xy -74 4
X = 4.77083 Y = 3.08333
ga-> q w2xy -72 8
X = 5.74306 Y = 5.41667
ga-> set line 2 1 6
SET LINE values: color = 2 style = 1 thickness = 6
ga-> draw rec 4.77083 3.08333 5.74306 5.41667
Related
I have a simple line graph, but the xticks are overlapping. Therefore I want to display only every 2nd xtick. I implemented this answer which worked for me in another graph. As you can see below it stops working after the 6th tick and I can't wrap my head around why.
My code is the following:
data = pf.cum_perc
fig, ax = plt.subplots(figsize=(10, 6))
ax.set_xlabel("Days", size=18)
ax.set_ylabel("Share of reviews", size = 18)
for label in ax.xaxis.get_ticklabels()[1::2]:
label.set_visible(False)
ax.plot(data)
pf.cum_perc is a column of a data frame (therefore a series) with the following data:
1 0.037599
2 0.089759
3 0.203477
4 0.302451
5 0.398169
6 0.486392
7 0.533514
8 0.538183
9 0.539411
10 0.550040
11 0.550716
12 0.553050
13 0.553726
14 0.654789
15 0.681084
16 0.706211
17 0.731462
18 0.756712
19 0.781594
20 0.807766
21 0.873687
(and so on)
The resulting graph:
Any help is greatly appreciated :)
As user #ImportanceOfBeingErnest suggested:
Solution 1:
Convert the x-axis data to numbers, so matplotbib takes care of the ticks automatically. In my case this is done by
pf.index = pf.index.map(int)
Solution 2:
Remove the ticks, after the graph is plotted, otherwise the objects don't exist yet and therefore can't be set invisible.
The new code would look like this:
data = pf.cum_perc
fig, ax = plt.subplots(figsize=(10, 6))
ax.set_xlabel("Days", size=18)
ax.set_ylabel("Share of reviews", size = 18)
ax.plot(data)
for label in ax.xaxis.get_ticklabels()[1::2]:
label.set_visible(False)
Please, i have a question about gnuplot.
Here is the file i work on:
1 129 130
2 129 129
3 129 130
4 129 129
5 129 ---
As you see the last line has no value in the third column.
Here is my command:
plot "mesuresSecondscen.txt" using 1:2 with linespoints lt 26 pt 26 tit 'Kernel of 129s' axis x1y1, "mesuresSecondscen.txt" using 1:3 with linespoints lt 21 pt 13 tit 'With-My-Approach' axis x1y1
Example: http://tinyurl.com/p2rfde9
I'd like to set the symbol 'X' in red in the place of the absent value
Is that possible please ?
Thank you so much for answer.
Kind regards.
There is a fundamental problem with your question, which is that you want to place a red "X", but where? If the value is missing you need to provide the coordinate value in some other way to know where you want to place the symbol. Anyway, for demonstration purposes I will assume you want to place it where the second column value lies. The function valid(n) can test if the value in column n is valid (returns 1) or not (returns 0). Using a conditional expression we can ask gnuplot to place a big red "X" at y = column(2) every time it encounters non-valid data:
plot "mesuresSecondscen.txt" using 1:2 with linespoints lt 26 pt 26 tit 'Kernel of 129s' axis x1y1, \
"mesuresSecondscen.txt" using 1:3 with linespoints lt 21 pt 13 tit 'With-My-Approach' axis x1y1, \
"mesuresSecondscen.txt" u 1:(valid(3) == 1 ? 1/0 : $2) pt 2 lc 1 ps 3 lw 3
The last line tests if the third column's value is valid, if it is valid (valid(3) = 1) it ignores that point, if it is not valid (valid(3) = 0) it places a big red "X" at y = column(2).
I have a vb.net windows form chart control on a form that displays a line chart of data that is made available in milli-gravities.
e.g. 5 gravities is given as 5000 milli-gravities, meaning that the Y-axis label is 5000
Is it possible to plot the same data but, have the Y-axis use labels in gravities, instead of milli-gravities? That is, for a Y data point of 5000, the Y axis label should be 5, or in other words have label value = auto label value / 1000
The data is currently bound to the chart using the following syntax
Chart1.Series.Add("Z Axis") 'Add multiple series
Chart1.Series.Add("Z RMS")
For Each Series In Chart1.Series 'Set each series to line type
Series.ChartType = SeriesChartType.Line
Next
Chart1.ChartAreas(0).AxisY.Maximum = 100000 'Start the Y axis limits at 100 gravities
Chart1.ChartAreas(0).AxisY.Minimum = 100000 'The max & min are changeable by user input
Chart1.ChartAreas(0).RecalculateAxesScale()
Chart1.Series("Z Axis").Points.DataBindY(record.Samples, "Z") 'Add the Y data points
Chart1.Series("Z RMS").Points.DataBindY(record.Samples, "RmsZ")
I thought maybe setting the Chart1.ChartAreas(0).AxisY.LabelStyle.Format might help, but I'm not sure how to use a format string to shorten an integer?
I'm using the following gnuplot commands to create a plot:
#!/bin/bash
gnuplot << 'EOF'
set term postscript portrait color enhanced
set output 'out.ps'
plot 'data_file' u 3:2 w points , '' u 3:2:($4!=-3.60 ? $1:'aaa') w labels
EOF
where data_file looks like this:
O4 -1.20 -0.33 -5.20
O9.5 -1.10 -0.30 -3.60
B0 -1.08 -0.30 -3.25
B0.5 -1.00 -0.28 -2.60
B1.5 -0.90 -0.25 -2.10
B2.5 -0.80 -0.22 -1.50
B3 -0.69 -0.20 -1.10
I want gnuplot to label all points with the strings found in column 1, except the one where column 4 is equal to -3.60 in which case I want the aaa string. What I'm getting is that the $4=-3.60 data point is being labeled correctly as aaa, but the rest are not being labeled at all.
Update: gnuplot has no problem showing numbers as labels using the conditional statement, ie: any column but 1 is correctly displayed as a label for each point respecting the conditions imposed. That is, this line displays column 2 (numbres) as point labels respecting the conditional statement:
plot 'data_file' u 3:2 w points , '' u 3:2:($4!=-3.60 ? $2:'aaa') w labels
Update 2: It also has no problem in plotting column 1 as point labels if I plot it as a whole, ie not using a conditional statement. That is, this line plots correctly all the point labels in column 1 (strings):
plot 'data_file' u 3:2 w points , '' u 3:2:1 w labels
So clearly the problem is in using the conditional statement together with the strings column. Any of these used separately works just fine.
In a more clean way maybe, this should work. It seems label can't display a computed number if it isn't turned in a string.
#!/bin/bash
gnuplot << 'EOF'
set term postscript portrait color enhanced
set output 'out.ps'
plot 'data_file' u 3:2 w points , '' u 3:2:($4!=-3.60 ? sprintf("%d",$1):'aaa') w labels
EOF
Is this what you want?
#!/bin/bash
gnuplot << 'EOF'
set term postscript portrait color enhanced
set output 'out.ps'
plot 'data_file' u 3:2 w points , \
'' u (($4 == -3.60)? 1/0 : $3):2:1 w labels
EOF
All I do here is set (x) points where the column 4 equals -3.6 to NaN (1/0). Since gnuplot ignores those points, life is good. I think the problem with your script is that you were filtering a column where gnuplot expects string input -- although I haven't played around with it enough to verify that. I just switched the filter to a column where gnuplot expects numbers (the x position) and it works just fine.
I am trying plot data sets consisting of 3 coordinates:
X-coordinate, x-coordinate and the number of occurrences.
example:
1 2 10
3 1 2
3 2 1
I would like to draw for every line a dot at x,y with a diameter which is depending on the third value.
Is that possible with Gnuplot?
Create a 2D plot with variable point size. See the demo.
Example:
plot 'dataFile.dat' u 1:2:3 w points lt 1 pt 10 ps variable
This is basically equivalent to the existing answer, just shorter:
plot 'dataFile.dat' with circles
Credit: Gnuplot: plot with circles of a defined radius