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

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]
}

Related

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 pm3d map: different x2tics, y2tics

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

plotly python - fix colours for specific legend labels

I am making a pie chart that looks like this.
I want to make multiple pie charts for different sets of data and keep the colours fixed to the legend names, but when the order changes, the colour scheme follows the order.
Is there a way to pass a dict into the chart to fix the colours to specific items?
[]
You cannot pass a dictionary with your colors, but you can specify the colors manually, set sort to False and pass the values always in the same order, e.g.
import plotly
fig = {
'data': [{'labels': ['Residential', 'Non-Residential', 'Utility'],
'values': [19, 26, 55],
'type': 'pie',
'sort': False,
'marker': {'colors': ['rgb(255, 0, 0)',
'rgb(0, 255, 0)',
'rgb(0, 0, 255)']
}
}]
}
fig = {
'data': [{'labels': ['Residential', 'Non-Residential', 'Utility'],
'values': [100, 10, 25],
'type': 'pie',
'sort': False,
'marker': {'colors': ['rgb(255, 0, 0)',
'rgb(0, 255, 0)',
'rgb(0, 0, 255)']
}
}]
}
plotly.offline.plot(fig)

Fill area below a dashed line

Right now I have the following data:
[{
data : [[3, 4], [6, 5]],
lines : { show : true, fill : true, steps : true },
dashes: { show: true, lineWidth: 1 },
color : 'red',
label : 'Data series'
}]
If I change lines.show to false then the area below the line does not get filled. dashes does not have a show property.
Is it possible to fill the area below a dotted line?
I found a solution: Show the line and set its width to 0.
lines : { show : true, lineWidth : 0}

add colorstop dynamically in fabric.js

I have been working on this for about a week now and I still have no idea of how to DYNAMICALLY add a colorstop to a gradient fill.
I can fill an object with a gradient fill, but how do I add a new colorstop to it after it has been created?
circle.setGradient('fill',
{
type: 'linear',
x1: 0,
y1: -circle.height / 2,
x2: 0,
y2: circle.height / 2,
colorStops:
{
0: '#000',
1: '#f00'
}
});
canvas.add(circle);
Assuming I have the above code, how can I add a third colorStop (e.g. 0.5: 'blue') dynamically, after the fill has been created?
Help?

Resources