Gnuplot pm3d map: different x2tics, y2tics - gnuplot

I can plot a "ploe figure" with:
degtorad(x)=x/180*pi
radtodeg(x)=x/pi*180
set pm3d map
set pm3d interpolate 0,0
set logscale zcb
set palette model RGB rgbformulae 33,13,10
set size ratio 1
set xtics("{/Symbol b}=180{/Symbol \260}" 0)
set ytics("0" -90, "10" -80, "20" -70, "30" -60, "40" -50, "50" -40, "60" -30, "70" -20, "80" -10, "90" 0, "80" 10, "70" 20, "60" 30, "50" 40, "40" 50, "30" 60, "20" 70, "10" 80, "0" 90)
splot[-90:90][-90:90] 'TSC3.txt' u (radtodeg(cos(degtorad($1+90))*degtorad(90-$2))):(radtodeg(degtorad(90-$2)*sin(degtorad($1+90)))):3 notitle
where column 1 contains "beta", column 2 is "alpha" but it doesn't matter.
The question is
how to remove the right ticmarks (unset y2tics doesn't work)?
how to set "beta=0°" on the upper side (set x2tics("{/Symbol b}=0{/Symbol \260}" 0) doesn't work)?

The unlabelled tics on the right and top border have nothing to do with the x2- and y2-axis. They are the mirrored tics of the x- and y-axis. To switch the right tics off, use set ytics ... nomirror.
If I remember correctly, in earlier versions splot didn't work at all with x2 and y2 axes. At least with 5.2 you can link the x2 axis to have the same range as the x axis with set link x2 and then you can place tics on the x2 axis:
degtorad(x)=x/180*pi
radtodeg(x)=x/pi*180
set pm3d map
set pm3d interpolate 0,0
set logscale zcb
set palette model RGB rgbformulae 33,13,10
set size ratio 1
set link x2
set x2tics ("{/Symbol b}=180{/Symbol \260}" 0)
set ytics nomirror ("0" -90, "10" -80, "20" -70, "30" -60, "40" -50, "50" -40, "60" -30, "70" -20, "80" -10, "90" 0, "80" 10, "70" 20, "60" 30, "50" 40, "40" 50, "30" 60, "20" 70, "10" 80, "0" 90)
splot[-90:90][-90:90] 'TSC3.txt' u (radtodeg(cos(degtorad($1+90))*degtorad(90-$2))):(radtodeg(degtorad(90-$2)*sin(degtorad($1+90)))):3 notitle

Related

Plot two lines in one graph with each line own y-values

Using Matplotlib, I would like to plot two lines in one graph, where both lines have their own axis.
Currently, I have:
x = [3, 5, 7, 9, 10, 11, 13, 15, 17, 19, 20, 21, 23, 25, 27, 30, 35, 40, 45, 50]
y1 = [0.658431,0.702574,0.727149,0.760198,0.746229,0.768321,0.763344,0.764400,0.759935,0.758930,0.769689,0.773518,0.764118,0.780918,0.767377,0.766301,0.779629,0.774025,0.773127,0.782209]
y2 = [0.008676, 0.014630, 0.021286, 0.025562, 0.018247, 0.026771, 0.036187, 0.025633, 0.031402, 0.031140, 0.031333, 0.027820, 0.020359, 0.033351, 0.032603, 0.027474, 0.025250, 0.023103, 0.030988, 0.026503]
plt.plot(x, y1, label = "line 1")
plt.plot(x, y2, label = "line 2")
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Y1 and Y2')
plt.legend()
Which results in:
However, both lines look relatively flat as they are represented on the same axis and have a different scale. Instead, I would like an y-axis on the left from 0.66 to 0.78 (to represent y1) and I would like an y-axis on the right between 0 and 0.05 (to represent y2). Then, y1's values can be read on the left axis and y2's values can be read on the right axis and the relative changes are illustrated clearer.
How can I do this?
Based on #rperezsoto's comment, I have the following working code:
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('x-axis')
ax1.set_ylabel('AUC', color='blue')
ax1.plot(x, y1, color='blue')
ax1.tick_params(axis='y', labelcolor='blue')
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
color = 'tab:blue'
ax2.set_ylabel('Standard deviation', color='grey') # we already handled the x-label with ax1
ax2.plot(x, y2, color='grey')
ax2.tick_params(axis='y', labelcolor='grey')
fig.tight_layout() # otherwise the right y-label is slightly clipped
plt.title('Y1 and Y2')
plt.show()

edgecolors - how to color the border of markers

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter(0.028, 0.008, marker='_', s=300, lw = 4, color='blue', edgecolors= 'black', clip_on=False, zorder = 2)
plt.show()
Result:
When I write color = 'none', I get a white plot.
It seems that the marker you are using does not have an edge.
Indeed if you change the marker to
ax.scatter(0.028, 0.008, marker='o', s=300, lw = 4, color='blue', edgecolors= 'black', clip_on=False, zorder = 2)
You correctly get the output

Hue, colorbar, or scatterplot colors do not match in seaborn.scatterplot

Using an example from another post, I'm adding a color bar to a scatter plot. The idea is that both dot hue, and colorbar hue, should conform to the maximum and minimum possible, so that the colorbar can reflect the range of values in the hue:
x= [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]
y= [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]
z= [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 255]
df = pd.DataFrame(list(zip(x, y, z)), columns =['x', 'y', 'z'])
colormap=matplotlib.cm.viridis
#A continuous color bar needs to be added independently
norm = plt.Normalize(df.z.min(), df.z.max())
sm = plt.cm.ScalarMappable(cmap=colormap, norm=norm)
sm.set_array([])
fig = plt.figure(figsize = (10,8), dpi=300)
ax = fig.add_subplot(1,1,1)
sb.scatterplot(x="x", y="y",
hue="z",
hue_norm=(0,255),
data=df,
palette=colormap,
ax=ax
)
ax.legend(bbox_to_anchor=(0, 1), loc=2, borderaxespad=0., title='hue from sb.scatterplot')
ax.figure.colorbar(sm).set_label('hue from sm')
plt.xlim(0,255)
plt.ylim(0,255)
plt.show()
Note how the hue from the scatterplot, even with hue_norm, ranges up to 300. In turn, the hue from the colorbar ranges from 0 to 255. From experimenting with values in hue_norm, it seems that matplotlib always rounds it off so that you have a "good" (even?) number of intervals.
My questions are:
Is which one is showing an incorrect range: the scatterplot, the scatterplot legend, or the colorbar? And how to correct it?
How could you retrieve min and max hue from the scatterplot (in this case 0 and 300, respectively), in order to set them as maximum and minimum of the colorbar?
Do you really need to use seaborn's scatterplot(). Using a numerical hue is always quite messy.
The following code is much simpler and yields an unambiguous output
fig, ax = plt.subplots()
g = ax.scatter(df['x'],df['y'], c=df['z'], cmap=colormap)
fig.colorbar(g)

Gnuplot: x1y1 plot and x2y1 plot not sharing same xtics

I am trying to do a multiplot. Following are the 4 files that I used with
File1.csv
,col1,col2,col3,col4,col5,col6
10,-39, 0.7, 0, 0,99.3, 0
14,-42, 0.0, 0, 0, 100, 0
42,-64, 0, 0, 0, 100, 0
46,-67, 2.5, 0, 0,97.5, 0
50,-69, 7.6, 0, 0,92.4, 0
54,-75, 0, 0, 0, 100, 0
58,-78, 3.7, 0, 0,96.3, 0
62,-82, 69.0, 0, 0,31.0, 0
66,-85, 0, 0, 0, 0, 0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78, 2.1, 0, 0,97.9, 0
54,-74, 2.9, 0, 0,97.1, 0
50,-69, 2.3, 0, 0,97.7, 0
46,-65, 2.4, 0, 0,97.6, 0
42,-65, 0, 0, 0, 100, 0
14,-43, 1.5, 0, 0,98.5, 0
10,-40, 1.0, 0, 0,99.0, 0
File2.csv
,col1,col2,col3,col4,col5,col6
10,-39, 0.7, 0, 0,99.3, 0
14,-42, 0.0, 0, 0, 100, 0
42,-64, 0, 0, 0, 100, 0
46,-67, 2.5, 0, 0,97.5, 0
50,-69, 7.6, 0, 0,92.4, 0
54,-75, 0, 0, 0, 100, 0
58,-78, 3.7, 0, 0,96.3, 0
62,-82, 69.0, 0, 0,31.0, 0
66,-85, 0, 0, 0, 0, 0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78, 2.1, 0, 0,97.9, 0
54,-74, 2.9, 0, 0,97.1, 0
50,-69, 2.3, 0, 0,97.7, 0
46,-65, 2.4, 0, 0,97.6, 0
42,-65, 0, 0, 0, 100, 0
14,-43, 1.5, 0, 0,98.5, 0
10,-40, 1.0, 0, 0,99.0, 0
File3.csv
,col1,col2,col3,col4,col5,col6
10,-39, 0.7, 0, 0,99.3, 0
14,-42, 0.0, 0, 0, 100, 0
42,-64, 0, 0, 0, 100, 0
46,-67, 2.5, 0, 0,97.5, 0
50,-69, 7.6, 0, 0,92.4, 0
54,-75, 0, 0, 0, 100, 0
58,-78, 3.7, 0, 0,96.3, 0
62,-82, 69.0, 0, 0,31.0, 0
66,-85, 0, 0, 0, 0, 0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78, 2.1, 0, 0,97.9, 0
54,-74, 2.9, 0, 0,97.1, 0
50,-69, 2.3, 0, 0,97.7, 0
46,-65, 2.4, 0, 0,97.6, 0
42,-65, 0, 0, 0, 100, 0
14,-43, 1.5, 0, 0,98.5, 0
10,-40, 1.0, 0, 0,99.0, 0
File4.csv
,col1,col2,col3,col4,col5,col6
10,-39, 0.7, 0, 0,99.3, 0
14,-42, 0.0, 0, 0, 100, 0
42,-64, 0, 0, 0, 100, 0
46,-67, 2.5, 0, 0,97.5, 0
50,-69, 7.6, 0, 0,92.4, 0
54,-75, 0, 0, 0, 100, 0
58,-78, 3.7, 0, 0,96.3, 0
62,-82, 69.0, 0, 0,31.0, 0
66,-85, 0, 0, 0, 0, 0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78, 2.1, 0, 0,97.9, 0
54,-74, 2.9, 0, 0,97.1, 0
50,-69, 2.3, 0, 0,97.7, 0
46,-65, 2.4, 0, 0,97.6, 0
42,-65, 0, 0, 0, 100, 0
14,-43, 1.5, 0, 0,98.5, 0
10,-40, 1.0, 0, 0,99.0, 0
Gnuplot script I got is histogram graph on x1y1 axis and linespoint graph on x2y1 axis
set colors classic
set terminal png notransparent size 1800,640 truecolor medium
set output 'reading.png'
set grid front
set tmargin -1; set bmargin -1
set lmargin -1; set rmargin -1
set style data histogram
set style histogram rowstacked
set style fill solid
set boxwidth 0.5
set datafile separator ","
set xtics axis
set yrange [0:100]
set y2range [-100:-10]
set y2tics
set y2label "Y2Label"
set ylabel "YLabel"
set multiplot layout 4,1
unset xtics
unset key
plot for [COL=3:6] 'file1.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file2.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file3.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL:xtic(1) ti col,'' u 2:xtic(1) with linespoint axes x1y2
unset multiplot
The resultant graph that I got is having different starting points on x-axis. Can someone please help synchronize histogram and linespoint plots in this.
I can reproduce your result. Right away, I don't know why this shift is happening. Probably something with indexing starting at 0 or starting at 1. Maybe something with the header line or with the histogram style in combination with the linespoints plot.
A possible fix could be using column 0, i.e. ($0-1) (see help pseudocolumns) as x coordinate for the linespoints plot.
By the way, you don't have to use xtic(1) mulitple times, it is identical anyway.
Your plot command would shorten to:
plot for [COL=3:6] 'file1.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
plot for [COL=3:6] 'file2.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
plot for [COL=3:6] 'file3.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL axes x1y1 ti col, '' u ($0-1):2:xtic(1) w lp axes x1y2

how to set zoom range for time ("%H:%M") in flot chart?

i have to set min and max zoom range for time. for example 00:00 to 23:00.
xaxis: {
mode: "time",
font: { color: "black"},
timezone: "browser",
timeformat :"%H:%M",
labelWidth: 30,
zoomRange: [0, 0]
}

Resources