hbar bokeh 1.3.4 with categorical data - python

I am trying to build a categorical plot with hbar in bokeh, though it seems a bit odd that it does not follow the same concept as the vbar. I have tried few variations and I still have not been able to plot the data, I am only getting an empty canvas. If someone could help me out, it would be much appreciated.
I am using bokeh 1.3.4 in my system and in an webapp I am building in Flask, so it has to be either this version or below(feels a bit demanding, but it is software requirements).
I have done it with pandas_bokeh which makes it very simple, though I am adding interactivity to the plots to allow the viewer to play around and pandas_bokeh does the job and you ended up not learning it properly.
webapp draft so far
rX = df3.index.values
xL = ['Dublin New', 'Ireland New','Dublin Existing','Ireland Existing']
labelDict = {'2010': xL, '2011': xL, '2012': xL, '2013': xL, '2014': xL,'2015': xL,'2016': xL,'2017': xL, '2018': xL}
sourceT = ColumnDataSource(data=dict(x=df3.index.values,
y=df3['Dublin New'],
y1=df3['Ireland New'],
y2=df3['Dublin Existing'],
y3=df3['Ireland Existing']))
pT = figure(y_range=FactorRange(*labelDict), plot_height=350, plot_width=550, title='Properties Transactions in Ireland', tools='pan, wheel_zoom, box_zoom, reset')
pT.hbar(y=dodge('x', -0.5, range=pT.y_range), height=0.3, right='y', fill_color="#FDE724", source=sourceT)
#pT.hbar(y=dodge('x', -0.25, range=pT.y_range), height=0.3, right='y1', fill_color='#35B778', source=sourceT)
show(pT)
Here is the plot I would like to reproduce using bokeh, instead pandas_bokeh.
Thanks in advance for the help.

The value for the range parameter of the dodge should be the actual range:
range=pT.y_range # GOOD
You are passing the range end property, which is a number:
range=pT.y_range.end # BAD
EDIT: Without a complete, minimal reproducer, it is not possible to directly fix your code. The best that can be offered is a complete working example that demonstrates that hbar does work exactly equivalently to vbar, that hopefully will be useful to you by comparison, to figure out where your full code strays:
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.transform import dodge
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ['2015', '2016', '2017']
data = {'fruits' : fruits,
'2015' : [2, 1, 4, 3, 2, 4],
'2016' : [5, 3, 3, 2, 4, 6],
'2017' : [3, 2, 4, 4, 5, 3]}
source = ColumnDataSource(data=data)
p = figure(y_range=fruits, x_range=(0, 10), plot_width=250, title="Fruit Counts by Year",
toolbar_location=None, tools="")
p.hbar(y=dodge('fruits', -0.25, range=p.y_range), right='2015', height=0.2, source=source,
color="#c9d9d3")
p.hbar(y=dodge('fruits', 0.0, range=p.y_range), right='2016', height=0.2, source=source,
color="#718dbf")
p.hbar(y=dodge('fruits', 0.25, range=p.y_range), right='2017', height=0.2, source=source,
color="#e84d60")
p.y_range.range_padding = 0.1
p.ygrid.grid_line_color = None
show(p)

#bigreddot Thanks a lot. I followed your approach and it works smoothly. I will try to work reserve the axis as I would rather to have the years in the yaxis.
Anyhow I really appreciated your help.
varT = ['Dublin New', 'Ireland New', 'Dublin Existing','Ireland Existing']
yearsT = df3.index.values.tolist()
dataT = {'var': var,
'2010': df3.iloc[0].values, '2011': df3.iloc[1].values,
'2012': df3.iloc[2].values, '2013': df3.iloc[3].values,
'2014': df3.iloc[4].values, '2015': df3.iloc[5].values,
'2016': df3.iloc[6].values, '2017': df3.iloc[7].values,
'2018': df3.iloc[8].values,
}
sourceTs = ColumnDataSource(data=dataT)
pT1 = figure(y_range=var, x_range=(0, df3.values.max()), plot_width=450, title='Properties Transactions in Ireland', tools='pan, wheel_zoom, box_zoom, reset')
pT1.hbar(y=dodge('var', -0.4, range=pT1.y_range), right='2010', height=0.1, source=sourceTs, color='#440154', legend=value('2010'))
pT1.hbar(y=dodge('var', -0.3, range=pT1.y_range), right='2011', height=0.1, source=sourceTs, color='#46317E', legend=value('2011'))
pT1.hbar(y=dodge('var', -0.2, range=pT1.y_range), right='2012', height=0.1, source=sourceTs, color='#365A8C', legend=value('2012'))
pT1.hbar(y=dodge('var', -0.1, range=pT1.y_range), right='2013', height=0.1, source=sourceTs, color='#277E8E', legend=value('2013'))
pT1.hbar(y=dodge('var', 0, range=pT1.y_range), right='2014', height=0.1, source=sourceTs, color='#1EA087', legend=value('2014'))
pT1.hbar(y=dodge('var', 0.1, range=pT1.y_range), right='2015', height=0.1, source=sourceTs, color='#49C16D', legend=value('2015'))
pT1.hbar(y=dodge('var', 0.2, range=pT1.y_range), right='2016', height=0.1, source=sourceTs, color='#9DD93A', legend=value('2016'))
pT1.hbar(y=dodge('var', 0.3, range=pT1.y_range), right='2017', height=0.1, source=sourceTs, color='#FDE724', legend=value('2017'))
pT1.hbar(y=dodge('var', 0.4, range=pT1.y_range), right='2018', height=0.1, source=sourceTs, color='#AADB32', legend=value('2018'))
pT1.legend.location='bottom_right'
#pT1.y_range.range_padding = 0.1
pT1.grid.grid_line_color = None
tick_labels_pt = {'10000':'10K','20000':'20K','30000':'30K','40000':'40K','50000':'50K'}
pT1.xaxis.major_label_overrides = tick_labels_pt
pT1.legend.background_fill_alpha=None
pT1.legend.border_line_alpha=0
pT1.legend.label_text_font_size = "11px"
pT1.legend.click_policy="hide"
pT1.title.text_font_size = '15px'
pT1.axis.major_label_text_font_style = 'bold'
#pT1.xaxis.major_label_text_font_style = 'bold'
pT1.toolbar.autohide = True
show(pT1)
Here is the outcome:
with the axis reversed:
varpti = ['Dublin New', 'Ireland New', 'Dublin Existing','Ireland Existing']
#the values of the y axis has to be in str format
yearspti = '2010','2011','2012', '2013', '2014', '2015', '2016', '2017', '2018' #df3.index.values.tolist()
datapti = {'years': yearspti,
'Dublin New': df3['Dublin New'].values,
'Ireland New': df3['Ireland New'].values,
'Dublin Existing': df3['Dublin Existing'].values,
'Ireland Existing': df3['Ireland Existing'].values
}
sourcepti = ColumnDataSource(data=datapti)
pti = figure(y_range=yearspti, x_range=(0, df3.values.max()), plot_height=500, plot_width=450, title='Properties Transactions in Ireland', tools='pan, wheel_zoom, box_zoom, reset')
pti.hbar(y=dodge('years', -0.2, range=pti.y_range), right='Dublin New', height=0.1, source=sourcepti, color='#440154', legend=value('Dublin New'))
pti.hbar(y=dodge('years', 0, range=pti.y_range), right='Ireland New', height=0.1, source=sourcepti, color='#30678D', legend=value('Ireland New'))
pti.hbar(y=dodge('years', 0.2, range=pti.y_range), right='Dublin Existing', height=0.1, source=sourcepti, color='#35B778', legend=value('Dublin Exsiting'))
pti.hbar(y=dodge('years', 0.4, range=pti.y_range), right='Ireland Existing', height=0.1, source=sourcepti, color='#FDE724', legend=value('Ireland Exsiting'))

Related

How to add images to each row in a Plotly Table?

I would like to add images to the rows in a Plotly Table, but could not find a good solution.
As an alternative option, I am using the method add_layout_image() placing the images approximately at the row space - see the example of what I am trying to achieve.
Anyone has a better solution!?
import plotly.graph_objects as go
import pandas as pd
import base64
data = {'team': {1: 'Sales team 1', 2: 'Sales team 2', 3: 'Sales team 3'},
'award': {1: '', 2: '', 3: ''},
'performance': {1: '67.00%', 2: '45.00%', 3: '35.00%'}}
df = pd.DataFrame(data)
fig = go.Figure(data=[go.Table(
columnwidth=[40, 40, 40],
header=dict(
values=list(df.columns),
height=35),
cells=dict(
values=[df.team,
df.award,
df.performance],
align=['center', 'center', 'center'],
font=dict(color='black', size=18),
height=45)
)])
heightRow = fig.data[0].cells.height
numberRow = fig.data[0].cells.values[0].__len__()
image_1st = 'medal1st.png'
image_1st_base64 = base64.b64encode(open(image_1st, 'rb').read())
step_y = 1 / numberRow * .2
coordinate_y = 0
for index, eachRow in enumerate(df.iterrows()):
fig.add_layout_image(
source='data:image/png;base64,{}'.format(image_1st_base64.decode()),
x=0.5,
y=.9 - coordinate_y,
xref="x domain",
yref="y domain",
xanchor="center",
yanchor="bottom",
sizex=.055,
sizey=.055,
)
coordinate_y = coordinate_y + step_y
fig.show()

Find local maxima in data from dataframe

Is there a way to find the local maxima from data I get from CSV file and put its value on the plot?
The x and y values that are in a pandas dataframe look something like this
x = 1598.78, 1596.85, 1594.92, 1592.99, 1591.07, 1589.14, 1587.21, 1585.28, 1583.35, 1581.42, 1579.49, 1577.57, 1575.64, 1573.71, 1571.78, 1569.85, 1567.92, 1565.99, 1564.07, 1562.14, 1560.21, 1558.28, 1556.35, 1554.42, 1552.49, 1550.57, 1548.64, 1546.71, 1544.78, 1542.85, 1540.92, 1538.99, 1537.07, 1535.14, 1533.21, 1531.28, 1529.35, 1527.42, 1525.49, 1523.57, 1521.64, 1519.71, 1517.78, 1515.85, 1513.92, 1511.99, 1510.07, 1508.14, 1506.21, 1504.28, 1502.35, 1500.42, 1498.49, 1496.57, 1494.64, 1492.71, 1490.78, 1488.85, 1486.92, 1484.99, 1483.07, 1481.14, 1479.21, 1477.28, 1475.35, 1473.42, 1471.49, 1469.57, 1467.64, 1465.71, 1463.78, 1461.85, 1459.92, 1457.99, 1456.07, 1454.14, 1452.21, 1450.28, 1448.35, 1446.42, 1444.49, 1442.57, 1440.64, 1438.71, 1436.78, 1434.85, 1432.92, 1430.99, 1429.07, 1427.14, 1425.21, 1423.28, 1421.35, 1419.42, 1417.49, 1415.57, 1413.64, 1411.71, 1409.78, 1407.85, 1405.92, 1403.99, 1402.07, 1400.14
y = 0.640, 0.624, 0.609, 0.594, 0.581, 0.569, 0.558, 0.547, 0.537, 0.530, 0.523, 0.516, 0.508, 0.502, 0.497, 0.491, 0.487, 0.484, 0.481, 0.480, 0.479, 0.482, 0.490, 0.503, 0.520, 0.542, 0.566, 0.586, 0.600, 0.606, 0.593, 0.569, 0.557, 0.548, 0.538, 0.531, 0.527, 0.524, 0.522, 0.522, 0.523, 0.525, 0.526, 0.527, 0.530, 0.534, 0.536, 0.539, 0.547, 0.553, 0.557, 0.563, 0.573, 0.599, 0.654, 0.738, 0.852, 0.891, 0.810, 0.744, 0.711, 0.694, 0.686, 0.683, 0.683, 0.690, 0.700, 0.706, 0.713, 0.723, 0.731, 0.732, 0.737, 0.756, 0.779, 0.786, 0.790, 0.794, 0.802, 0.815, 0.827, 0.832, 0.831, 0.826, 0.823, 0.828, 0.834, 0.834, 0.832, 0.832, 0.831, 0.825, 0.816, 0.804, 0.798, 0.794, 0.786, 0.775, 0.764, 0.752, 0.739, 0.722, 0.708, 0.697
and I'm trying to get something like this.
P.S. Note that numeric values were added with the plt.text function just to exemplify what I want.
x = [1598.78, 1596.85, 1594.92, 1592.99, 1591.07, 1589.14, 1587.21, 1585.28, 1583.35, 1581.42, 1579.49, 1577.57, 1575.64, 1573.71, 1571.78, 1569.85, 1567.92, 1565.99, 1564.07, 1562.14, 1560.21, 1558.28, 1556.35, 1554.42, 1552.49, 1550.57, 1548.64, 1546.71, 1544.78, 1542.85, 1540.92, 1538.99, 1537.07, 1535.14, 1533.21, 1531.28, 1529.35, 1527.42, 1525.49, 1523.57, 1521.64, 1519.71, 1517.78, 1515.85, 1513.92, 1511.99, 1510.07, 1508.14, 1506.21, 1504.28, 1502.35, 1500.42, 1498.49, 1496.57, 1494.64, 1492.71, 1490.78, 1488.85, 1486.92, 1484.99, 1483.07, 1481.14, 1479.21, 1477.28, 1475.35, 1473.42, 1471.49, 1469.57, 1467.64, 1465.71, 1463.78, 1461.85, 1459.92, 1457.99, 1456.07, 1454.14, 1452.21, 1450.28, 1448.35, 1446.42, 1444.49, 1442.57, 1440.64, 1438.71, 1436.78, 1434.85, 1432.92, 1430.99, 1429.07, 1427.14, 1425.21, 1423.28, 1421.35, 1419.42, 1417.49, 1415.57, 1413.64, 1411.71, 1409.78, 1407.85, 1405.92, 1403.99, 1402.07, 1400.14]
y = [0.640, 0.624, 0.609, 0.594, 0.581, 0.569, 0.558, 0.547, 0.537, 0.530, 0.523, 0.516, 0.508, 0.502, 0.497, 0.491, 0.487, 0.484, 0.481, 0.480, 0.479, 0.482, 0.490, 0.503, 0.520, 0.542, 0.566, 0.586, 0.600, 0.606, 0.593, 0.569, 0.557, 0.548, 0.538, 0.531, 0.527, 0.524, 0.522, 0.522, 0.523, 0.525, 0.526, 0.527, 0.530, 0.534, 0.536, 0.539, 0.547, 0.553, 0.557, 0.563, 0.573, 0.599, 0.654, 0.738, 0.852, 0.891, 0.810, 0.744, 0.711, 0.694, 0.686, 0.683, 0.683, 0.690, 0.700, 0.706, 0.713, 0.723, 0.731, 0.732, 0.737, 0.756, 0.779, 0.786, 0.790, 0.794, 0.802, 0.815, 0.827, 0.832, 0.831, 0.826, 0.823, 0.828, 0.834, 0.834, 0.832, 0.832, 0.831, 0.825, 0.816, 0.804, 0.798, 0.794, 0.786, 0.775, 0.764, 0.752, 0.739, 0.722, 0.708, 0.697]
import matplotlib.pyplot as plt
# The slope of a line is a measure of its steepness. Mathematically, slope is calculated as "rise over run" (change in y divided by change in x).
slope = [np.sign((y[i] - y[i-1]) / (x[i] - x[i-1])) for i in range(1, len(y))]
x_prev = slope[0]
optima_dic={'minima':[], 'maxima':[]}
for i in range(1, len(slope)):
if slope[i] * x_prev == -1: #slope changed
if x_prev == 1: # slope changed from 1 to -1
optima_dic['maxima'].append(i)
else: # slope changed from -1 to 1
optima_dic['minima'].append(i)
x_prev=-x_prev
from matplotlib.pyplot import text
plt.rcParams["figure.figsize"] = (20,10)
ix = 0
for x_, y_ in zip(x, y):
plt.plot(x_, y_, 'o--', color='grey')
if(ix in optima_dic['minima']):
plt.text(x_, y_, s = x_, fontsize=10)
ix += 1

Add limit orders on side of the chart Plotly

Trying to add limit order on right side that will show where limit orders was places and volume of that limit. if it sell order make it red and if buy green. If volume of limit order is big make line bigger. There is quick example what I'm looking for.
Here is full code that I have with chart data: https://textbin.net/noz678jlue
chartData = {'Price': [0.965879, 0.964773, 0.96447, 0.961223, 0.958788, 0.956747, 0.958788, 0.959872, 0.959868, 0.960104, 0.961375, 0.962256, 0.963297, 0.963315, 0.964611, 0.964513, 0.963761, 0.963763, 0.963922, 0.963907, 0.963857, 0.963265, 0.963293, 0.963171, 0.96318, 0.963707, 0.964389, 0.964352, 0.963077, 0.961785, 0.959572, 0.958703, 0.959223, 0.95819, 0.952994, 0.95124, 0.950693, 0.950906, 0.95184, 0.951838, 1.053997, 1.060501, 1.060672, 1.060486, 1.060171, 1.060241, 1.059292, 1.059263, 1.059205, 0.95906, 0.954787, 0.954901, 0.954993, 0.955447, 0.955465, 0.955626, 0.953638, 0.952751, 0.951972, 0.950729, 0.950532, 0.952849, 0.952773, 0.952682, 0.952351, 0.948383, 0.94847, 0.948451, 0.95198, 0.952234, 0.951982, 0.952163, 0.952301, 0.952407, 0.955843, 0.956628, 0.957734, 0.957548, 0.95771, 0.956813, 0.958674, 0.958295, 0.954697, 0.953861, 0.955926, 0.953264, 0.951443, 0.950245, 0.949453, 0.949492, 0.948764, 0.946932, 0.949487, 0.950302, 0.950381, 0.949979, 0.948601, 0.949252, 0.949217, 0.949271, 0.947859, 0.947683, 0.947763, 0.947593, 0.948247, 0.9483, 0.948568, 0.947236, 0.946515, 0.946128, 0.946793, 0.946244, 0.951683, 0.951324, 0.950662, 0.949001, 0.947648, 0.946191, 0.946928, 0.933038, 0.92239, 0.923197, 0.925719, 0.937193, 0.93354, 0.932933, 0.932073, 0.931954, 0.932393, 0.931602, 0.932908, 0.932966, 0.933866, 0.931223, 0.929834, 0.933195, 0.936534, 0.935959, 0.932762, 0.931187, 0.937434, 0.937664, 0.936378, 0.934742, 0.934742], 'Date': [1652117700000, 1652118000000, 1652118300000, 1652118600000, 1652118900000, 1652119200000, 1652119500000, 1652119800000, 1652120100000, 1652120400000, 1652120700000, 1652121000000, 1652121300000, 1652121600000, 1652121900000, 1652122200000, 1652122500000, 1652122800000, 1652123100000, 1652123400000, 1652123700000, 1652124000000, 1652124300000, 1652124600000, 1652124900000, 1652125200000, 1652125500000, 1652125800000, 1652126100000, 1652126400000, 1652126700000, 1652127000000, 1652127300000, 1652127600000, 1652127900000, 1652128200000, 1652128500000, 1652128800000, 1652129100000, 1652129400000, 1652129700000, 1652130000000, 1652130300000, 1652130600000, 1652130900000, 1652131200000, 1652131500000, 1652131800000, 1652132100000, 1652132400000, 1652132700000, 1652133000000, 1652133300000, 1652133600000, 1652133900000, 1652134200000, 1652134500000, 1652134800000, 1652135100000, 1652135400000, 1652135700000, 1652136000000, 1652136300000, 1652136600000, 1652136900000, 1652137200000, 1652137500000, 1652137800000, 1652138100000, 1652138400000, 1652138700000, 1652139000000, 1652139300000, 1652139600000, 1652139900000, 1652140200000, 1652140500000, 1652140800000, 1652141100000, 1652141400000, 1652141700000, 1652142000000, 1652142300000, 1652142600000, 1652142900000, 1652143200000, 1652143500000, 1652143800000, 1652144100000, 1652144400000, 1652144700000, 1652145000000, 1652145300000, 1652145600000, 1652145900000, 1652146200000, 1652146500000, 1652146800000, 1652147100000, 1652147400000, 1652147700000, 1652148000000, 1652148300000, 1652148600000, 1652148900000, 1652149200000, 1652149500000, 1652149800000, 1652150100000, 1652150400000, 1652150700000, 1652151000000, 1652151300000, 1652151600000, 1652151900000, 1652152200000, 1652152500000, 1652152800000, 1652153100000, 1652153400000, 1652153700000, 1652154000000, 1652154300000, 1652154600000, 1652154900000, 1652155200000, 1652155500000, 1652155800000, 1652156100000, 1652156400000, 1652156700000, 1652157000000, 1652157300000, 1652157600000, 1652157900000, 1652158200000, 1652158500000, 1652158800000, 1652159100000, 1652159400000, 1652159700000, 1652160000000, 1652160300000, 1652160600000, 1652160636000]}
limitOrders = {"BUY":{"0.98": 50000, "0.93": 5555, "0.67": 300000, "0.85": 5555, "0.47": 300000, '0.57': 300000, "0.95": 5555}, "SELL":{"1.00": 50000, "0.83": 5555, "0.67": 300000, "0.75": 5555, "0.57": 300000, '0.67': 300000, "0.85": 5555}}
eastern = pytz.timezone('US/Eastern')
df: DataFrame = pd.DataFrame.from_dict(chatData).fillna(method="backfill")
df['Date'] = pd.to_datetime(df['Date'], unit='ms').dt.tz_localize('UTC').dt.tz_convert(eastern)
x = df['Date']
y = df['Price']
layout = Layout(
autosize=True,
width=1980,
height=1080,
margin=dict(l=10, r=10, t=80, b=10),
title="<b>TEST</b>",
paper_bgcolor='rgb(0.03,0.00,0.07)',
plot_bgcolor='rgb(0.03,0.00,0.07)',
yaxis_tickformat=".3f",
title_x=0.5,
font=dict(
family="Amarante,cursive",
size=25,
color="White")
)
fig = go.Figure([
go.Scatter(x=x, y=1.01 * np.ones_like(y), opacity=0.5, line_width=0, showlegend=False),
go.Scatter(x=x, y=y, fill='tonexty', fillcolor="#240050", line=dict(color="#940099"), line_shape='spline',
opacity=0, showlegend=False)
], layout=layout)
fig.show()
You can use plotly shapes to place down the line segments representing limit orders, and annotations to place down the text with the corresponding volume amount. However, you will need to increase the right margin so the annotations are visible.
import pytz
import numpy as np
import pandas as pd
import plotly.graph_objects as go
chartData = {'Price': [0.965879, 0.964773, 0.96447, 0.961223, 0.958788, 0.956747, 0.958788, 0.959872, 0.959868, 0.960104, 0.961375, 0.962256, 0.963297, 0.963315, 0.964611, 0.964513, 0.963761, 0.963763, 0.963922, 0.963907, 0.963857, 0.963265, 0.963293, 0.963171, 0.96318, 0.963707, 0.964389, 0.964352, 0.963077, 0.961785, 0.959572, 0.958703, 0.959223, 0.95819, 0.952994, 0.95124, 0.950693, 0.950906, 0.95184, 0.951838, 1.053997, 1.060501, 1.060672, 1.060486, 1.060171, 1.060241, 1.059292, 1.059263, 1.059205, 0.95906, 0.954787, 0.954901, 0.954993, 0.955447, 0.955465, 0.955626, 0.953638, 0.952751, 0.951972, 0.950729, 0.950532, 0.952849, 0.952773, 0.952682, 0.952351, 0.948383, 0.94847, 0.948451, 0.95198, 0.952234, 0.951982, 0.952163, 0.952301, 0.952407, 0.955843, 0.956628, 0.957734, 0.957548, 0.95771, 0.956813, 0.958674, 0.958295, 0.954697, 0.953861, 0.955926, 0.953264, 0.951443, 0.950245, 0.949453, 0.949492, 0.948764, 0.946932, 0.949487, 0.950302, 0.950381, 0.949979, 0.948601, 0.949252, 0.949217, 0.949271, 0.947859, 0.947683, 0.947763, 0.947593, 0.948247, 0.9483, 0.948568, 0.947236, 0.946515, 0.946128, 0.946793, 0.946244, 0.951683, 0.951324, 0.950662, 0.949001, 0.947648, 0.946191, 0.946928, 0.933038, 0.92239, 0.923197, 0.925719, 0.937193, 0.93354, 0.932933, 0.932073, 0.931954, 0.932393, 0.931602, 0.932908, 0.932966, 0.933866, 0.931223, 0.929834, 0.933195, 0.936534, 0.935959, 0.932762, 0.931187, 0.937434, 0.937664, 0.936378, 0.934742, 0.934742], 'Date': [1652117700000, 1652118000000, 1652118300000, 1652118600000, 1652118900000, 1652119200000, 1652119500000, 1652119800000, 1652120100000, 1652120400000, 1652120700000, 1652121000000, 1652121300000, 1652121600000, 1652121900000, 1652122200000, 1652122500000, 1652122800000, 1652123100000, 1652123400000, 1652123700000, 1652124000000, 1652124300000, 1652124600000, 1652124900000, 1652125200000, 1652125500000, 1652125800000, 1652126100000, 1652126400000, 1652126700000, 1652127000000, 1652127300000, 1652127600000, 1652127900000, 1652128200000, 1652128500000, 1652128800000, 1652129100000, 1652129400000, 1652129700000, 1652130000000, 1652130300000, 1652130600000, 1652130900000, 1652131200000, 1652131500000, 1652131800000, 1652132100000, 1652132400000, 1652132700000, 1652133000000, 1652133300000, 1652133600000, 1652133900000, 1652134200000, 1652134500000, 1652134800000, 1652135100000, 1652135400000, 1652135700000, 1652136000000, 1652136300000, 1652136600000, 1652136900000, 1652137200000, 1652137500000, 1652137800000, 1652138100000, 1652138400000, 1652138700000, 1652139000000, 1652139300000, 1652139600000, 1652139900000, 1652140200000, 1652140500000, 1652140800000, 1652141100000, 1652141400000, 1652141700000, 1652142000000, 1652142300000, 1652142600000, 1652142900000, 1652143200000, 1652143500000, 1652143800000, 1652144100000, 1652144400000, 1652144700000, 1652145000000, 1652145300000, 1652145600000, 1652145900000, 1652146200000, 1652146500000, 1652146800000, 1652147100000, 1652147400000, 1652147700000, 1652148000000, 1652148300000, 1652148600000, 1652148900000, 1652149200000, 1652149500000, 1652149800000, 1652150100000, 1652150400000, 1652150700000, 1652151000000, 1652151300000, 1652151600000, 1652151900000, 1652152200000, 1652152500000, 1652152800000, 1652153100000, 1652153400000, 1652153700000, 1652154000000, 1652154300000, 1652154600000, 1652154900000, 1652155200000, 1652155500000, 1652155800000, 1652156100000, 1652156400000, 1652156700000, 1652157000000, 1652157300000, 1652157600000, 1652157900000, 1652158200000, 1652158500000, 1652158800000, 1652159100000, 1652159400000, 1652159700000, 1652160000000, 1652160300000, 1652160600000, 1652160636000]}
limitOrders = {"BUY":{"0.98": 50000, "0.93": 5555, "0.67": 300000, "0.85": 5555, "0.47": 300000, '0.57': 300000, "0.95": 5555}, "SELL":{"1.00": 50000, "0.83": 5555, "0.67": 300000, "0.75": 5555, "0.57": 300000, '0.67': 300000, "0.85": 5555}}
eastern = pytz.timezone('US/Eastern')
df = pd.DataFrame.from_dict(chartData).fillna(method="backfill")
df['Date'] = pd.to_datetime(df['Date'], unit='ms').dt.tz_localize('UTC').dt.tz_convert(eastern)
x = df['Date']
y = df['Price']
layout = dict(
autosize=True,
width=1980,
height=1080,
margin=dict(l=10, r=200, t=80, b=10),
title="<b>TEST</b>",
paper_bgcolor='rgb(0.03,0.00,0.07)',
plot_bgcolor='rgb(0.03,0.00,0.07)',
yaxis_tickformat=".3f",
title_x=0.5,
font=dict(
family="Amarante,cursive",
size=25,
color="White")
)
fig = go.Figure([
go.Scatter(x=x, y=1.01 * np.ones_like(y), opacity=0.5, line_width=0, showlegend=False),
go.Scatter(x=x, y=y, fill='tonexty', fillcolor="#240050", line=dict(color="#940099"), line_shape='spline',
opacity=0, showlegend=False)
], layout=layout)
## add limit orders using annotations
## use paper coordinates to determine length in the x direction
max_limit_volume = 500000
max_limit_volume_length = 0.25
for limit_order_name,limit_order_info in limitOrders.items():
if limit_order_name == "BUY":
for y_value, volume in limit_order_info.items():
y_value = float(y_value)
fig.add_shape(type="line",
x0=1, y0=y_value, x1=1-0.1*volume/max_limit_volume, y1=y_value,
line=dict(color="green",width=3)
)
fig.add_annotation(
x=1.05, y=y_value,
yshift=-30, xref="paper",
text=f"${volume}", font=dict(color="white")
)
if limit_order_name == "SELL":
for y_value, volume in limit_order_info.items():
y_value = float(y_value)
fig.add_shape(type="line",
x0=1, y0=y_value, x1=1-0.1*volume/max_limit_volume, y1=y_value,
line=dict(color="red",width=3)
)
fig.add_annotation(
x=1.05, y=y_value,
yshift=-30e, xref="paper",
text=f"${volume}", font=dict(color="white")
)
fig.update_shapes(dict(xref='paper', yref='y'))
fig.show()

Matplotlib: contour plot with data interpolation

I use scipy.interpolate.griddata to interpolate my data for contour plot. The data have different scale on x and y axes:
from scipy.interpolate import griddata
xx = [0.0493, 0.0458, 0.0425, 0.0394, 0.0365, 0.0337, 0.0311, 0.0286, 0.0262, 0.024, 0.0219, 0.0198, 0.0179, 0.016, 0.0143, 0.0126, 0.0109, 0.0094, 0.0079, 0.0064, 0.005, 0.0037, 0.0024, 0.0012, 0.0, 0.0663, 0.0637, 0.0613, 0.059, 0.0567, 0.0546, 0.0525, 0.0506, 0.0487, 0.0469, 0.0451, 0.0434, 0.0418, 0.0402, 0.0387, 0.0373, 0.0359, 0.0345, 0.0332, 0.0319, 0.0307, 0.0295, 0.0283, 0.0272, 0.0261, 0.0792, 0.0774, 0.0756, 0.0739, 0.0722, 0.0706, 0.0691, 0.0676, 0.0661, 0.0647, 0.0633, 0.062, 0.0607, 0.0594, 0.0582, 0.057, 0.0559, 0.0547, 0.0536, 0.0526, 0.0515, 0.0505, 0.0495, 0.0486, 0.0477, 0.0919, 0.0905, 0.0891, 0.0878, 0.0865, 0.0852, 0.084, 0.0828, 0.0816, 0.0805, 0.0794, 0.0783, 0.0772, 0.0762, 0.0752, 0.0742, 0.0732, 0.0723, 0.0714, 0.0705, 0.0696, 0.0688, 0.0679, 0.0671, 0.0663, 0.1044, 0.1033, 0.1022, 0.1011, 0.1, 0.099, 0.098, 0.097, 0.096, 0.0951, 0.0942, 0.0933, 0.0924, 0.0915, 0.0907, 0.0898, 0.089, 0.0882, 0.0874, 0.0867, 0.0859, 0.0852, 0.0845, 0.0837, 0.083, 0.1168, 0.1159, 0.1149, 0.114, 0.1132, 0.1123, 0.1114, 0.1106, 0.1098, 0.109, 0.1082, 0.1074, 0.1066, 0.1059, 0.1052, 0.1045, 0.1037, 0.1031, 0.1024, 0.1017, 0.1011, 0.1004, 0.0998, 0.0992, 0.0985, 0.1291, 0.1283, 0.1275, 0.1267, 0.126, 0.1252, 0.1245, 0.1238, 0.123, 0.1223, 0.1217, 0.121, 0.1203, 0.1197, 0.119, 0.1184, 0.1178, 0.1172, 0.1166, 0.116, 0.1154, 0.1148, 0.1143, 0.1137, 0.1132]
yy = [0.6137, 0.8211, 1.0277, 1.2338, 1.4393, 1.6444, 1.8489, 2.053, 2.2567, 2.4601, 2.6631, 2.8658, 3.0682, 3.2703, 3.4722, 3.6738, 3.8752, 4.0763, 4.2773, 4.4781, 4.6787, 4.8791, 5.0794, 5.2795, 5.4795, 0.3217, 0.5059, 0.694, 0.8859, 1.0812, 1.2799, 1.4816, 1.6861, 1.8934, 2.1033, 2.3155, 2.5301, 2.7467, 2.9655, 3.1861, 3.4086, 3.6328, 3.8586, 4.0861, 4.315, 4.5453, 4.777, 5.01, 5.2442, 5.4795, 0.2447, 0.4154, 0.5919, 0.7737, 0.9606, 1.1524, 1.3488, 1.5496, 1.7547, 1.9638, 2.1767, 2.3932, 2.6133, 2.8367, 3.0633, 3.293, 3.5257, 3.7611, 3.9993, 4.2401, 4.4833, 4.729, 4.977, 5.2272, 5.4795, 0.1814, 0.3467, 0.5184, 0.696, 0.8795, 1.0685, 1.2629, 1.4624, 1.6668, 1.876, 2.0897, 2.3079, 2.5302, 2.7567, 2.987, 3.2212, 3.4591, 3.7004, 3.9452, 4.1933, 4.4446, 4.6989, 4.9563, 5.2165, 5.4795, 0.1202, 0.2837, 0.4538, 0.6303, 0.8128, 1.0012, 1.1953, 1.3949, 1.5998, 1.8099, 2.0249, 2.2448, 2.4693, 2.6983, 2.9318, 3.1694, 3.4112, 3.657, 3.9066, 4.16, 4.417, 4.6776, 4.9416, 5.2089, 5.4795, 0.0598, 0.2232, 0.3932, 0.5697, 0.7525, 0.9413, 1.136, 1.3365, 1.5425, 1.754, 1.9706, 2.1924, 2.4191, 2.6506, 2.8867, 3.1275, 3.3726, 3.6221, 3.8757, 4.1334, 4.3951, 4.6606, 4.93, 5.203, 5.4795, 0.0, 0.1638, 0.3344, 0.5115, 0.695, 0.8848, 1.0806, 1.2823, 1.4897, 1.7028, 1.9212, 2.145, 2.3739, 2.6078, 2.8466, 3.0903, 3.3385, 3.5914, 3.8486, 4.1102, 4.376, 4.646, 4.9199, 5.1978, 5.4795]
vv = [0.4829, 0.5196, 0.5541, 0.5866, 0.6173, 0.6463, 0.6738, 0.6998, 0.7246, 0.7481, 0.7706, 0.7919, 0.8123, 0.8318, 0.8504, 0.8683, 0.8854, 0.9017, 0.9175, 0.9326, 0.9471, 0.9611, 0.9745, 0.9875, 1.0, 0.4229, 0.4512, 0.4782, 0.5041, 0.5288, 0.5525, 0.5752, 0.597, 0.618, 0.6381, 0.6575, 0.6761, 0.6941, 0.7114, 0.7282, 0.7443, 0.7599, 0.775, 0.7895, 0.8036, 0.8173, 0.8305, 0.8433, 0.8557, 0.8678, 0.4044, 0.4259, 0.4467, 0.4668, 0.4862, 0.505, 0.5231, 0.5407, 0.5578, 0.5743, 0.5903, 0.6059, 0.621, 0.6356, 0.6498, 0.6637, 0.6771, 0.6902, 0.703, 0.7154, 0.7274, 0.7392, 0.7507, 0.7618, 0.7727, 0.3883, 0.4056, 0.4225, 0.4388, 0.4548, 0.4703, 0.4854, 0.5001, 0.5144, 0.5283, 0.5419, 0.5552, 0.5681, 0.5808, 0.5931, 0.6051, 0.6169, 0.6284, 0.6396, 0.6506, 0.6613, 0.6718, 0.6821, 0.6921, 0.7019, 0.3725, 0.3871, 0.4014, 0.4153, 0.4289, 0.4422, 0.4551, 0.4678, 0.4802, 0.4924, 0.5042, 0.5159, 0.5272, 0.5384, 0.5493, 0.56, 0.5704, 0.5807, 0.5907, 0.6006, 0.6102, 0.6197, 0.629, 0.6381, 0.6471, 0.3569, 0.3697, 0.3821, 0.3943, 0.4063, 0.418, 0.4295, 0.4407, 0.4518, 0.4626, 0.4732, 0.4836, 0.4938, 0.5038, 0.5137, 0.5233, 0.5328, 0.5421, 0.5513, 0.5603, 0.5691, 0.5778, 0.5863, 0.5947, 0.6029, 0.3415, 0.3529, 0.3641, 0.375, 0.3858, 0.3964, 0.4068, 0.417, 0.427, 0.4368, 0.4465, 0.456, 0.4654, 0.4745, 0.4836, 0.4925, 0.5012, 0.5098, 0.5182, 0.5265, 0.5347, 0.5428, 0.5507, 0.5585, 0.5662]
N=500
data_points = (xx, yy)
grid_points = (np.linspace(min(xx), max(xx), N), np.linspace(min(yy), max(yy), N))
vi = griddata(data_points, vv,
(grid_points[0][None, :], grid_points[1][:, None]), method='cubic')
plot(xx,yy, '.k')
contour(grid_points[0], grid_points[1], vi)
But I got ugly sharped contours:
However, if I scale for example the y axis, like this yy = [v/50. for v in yy], I got the smoothed plot:
How to get the smoothed contours with original axes scales?

plt.tricontourf(x,y,z) creating color values outside of data bounds

I am attempting to make compressor and turbine maps colored by efficiency. I have achieved this, but the tricontourf I am attempting leads to level colors outside of where my data even exists. I need to make sure the contour ends at the bounds of my data. Is there a way to achieve this?
My code:
import numpy as np
import matplotlib.pyplot as plt
alphaMap = np.array([0.000, 90.000])
NcMap = np.array([0.300, 0.400, 0.500, 0.600, 0.700, 0.750, 0.800, 0.850, 0.900, 0.950, 1.000, 1.050, 1.100, 1.150])
RlineMap = np.array([1.000, 1.200, 1.400, 1.600, 1.800, 2.000, 2.200, 2.400, 2.600, 2.800, 3.000])
WCmap = np.array([[[17.907, 19.339, 20.749, 22.136, 23.498, 24.833, 26.141, 27.420, 28.669, 29.887, 31.011],
[24.951, 26.742, 28.485, 30.177, 31.815, 33.397, 34.921, 36.385, 37.788, 39.128, 40.405],
[32.682, 34.715, 36.662, 38.520, 40.286, 41.958, 43.533, 45.011, 46.390, 47.669, 48.848],
[40.927, 43.115, 45.168, 47.083, 48.858, 50.492, 51.983, 53.331, 54.539, 55.607, 56.537],
[49.850, 52.122, 54.195, 56.068, 57.741, 59.215, 60.494, 61.580, 62.479, 63.197, 63.739],
[54.798, 57.066, 59.099, 60.897, 62.463, 63.800, 64.913, 65.810, 66.497, 66.983, 67.278],
[60.051, 62.252, 64.185, 65.851, 67.255, 68.405, 69.307, 69.973, 70.413, 70.638, 70.675],
[65.313, 67.427, 69.262, 70.824, 72.118, 73.153, 73.938, 74.484, 74.803, 74.907, 74.907],
[70.995, 72.902, 74.542, 75.920, 77.043, 77.920, 78.560, 78.974, 79.174, 79.198, 79.198],
[77.441, 78.904, 80.155, 81.199, 82.042, 82.690, 83.151, 83.434, 83.545, 83.548, 83.548],
[84.344, 85.211, 85.952, 86.572, 87.074, 87.460, 87.735, 87.903, 87.967, 87.968, 87.968],
[89.305, 89.687, 90.025, 90.320, 90.572, 90.783, 90.953, 91.083, 91.174, 91.227, 91.243],
[93.626, 93.712, 93.793, 93.868, 93.939, 94.004, 94.064, 94.120, 94.170, 94.216, 94.257],
[95.978, 95.989, 96.000, 96.012, 96.022, 96.033, 96.044, 96.054, 96.064, 96.074, 96.084]],
[[17.907, 19.339, 20.749, 22.136, 23.498, 24.833, 26.141, 27.420, 28.669, 29.887, 31.011],
[24.951, 26.742, 28.485, 30.177, 31.815, 33.397, 34.921, 36.385, 37.788, 39.128, 40.405],
[32.682, 34.715, 36.662, 38.520, 40.286, 41.958, 43.533, 45.011, 46.390, 47.669, 48.848],
[40.927, 43.115, 45.168, 47.083, 48.858, 50.492, 51.983, 53.331, 54.539, 55.607, 56.537],
[49.850, 52.122, 54.195, 56.068, 57.741, 59.215, 60.494, 61.580, 62.479, 63.197, 63.739],
[54.798, 57.066, 59.099, 60.897, 62.463, 63.800, 64.913, 65.810, 66.497, 66.983, 67.278],
[60.051, 62.252, 64.185, 65.851, 67.255, 68.405, 69.307, 69.973, 70.413, 70.638, 70.675],
[65.313, 67.427, 69.262, 70.824, 72.118, 73.153, 73.938, 74.484, 74.803, 74.907, 74.907],
[70.995, 72.902, 74.542, 75.920, 77.043, 77.920, 78.560, 78.974, 79.174, 79.198, 79.198],
[77.441, 78.904, 80.155, 81.199, 82.042, 82.690, 83.151, 83.434, 83.545, 83.548, 83.548],
[84.344, 85.211, 85.952, 86.572, 87.074, 87.460, 87.735, 87.903, 87.967, 87.968, 87.968],
[89.305, 89.687, 90.025, 90.320, 90.572, 90.783, 90.953, 91.083, 91.174, 91.227, 91.243],
[93.626, 93.712, 93.793, 93.868, 93.939, 94.004, 94.064, 94.120, 94.170, 94.216, 94.257],
[96.084, 96.074, 96.064, 96.054, 96.044, 96.033, 96.022, 96.012, 96.000, 95.989, 95.978]]])
effMap = np.array([[[.8070, .8291, .8461, .8566, .8586, .8497, .8170, .7410, .6022, .3674, .0000],
[.8230, .8454, .8628, .8741, .8775, .8708, .8419, .7732, .6477, .4372, .0916],
[.8411, .8631, .8805, .8921, .8966, .8918, .8671, .8065, .6959, .5124, .2168],
[.8565, .8783, .8957, .9077, .9131, .9099, .8883, .8338, .7340, .5696, .3083],
[.8662, .8879, .9055, .9179, .9239, .9219, .9024, .8520, .7600, .6096, .3739],
[.8699, .8917, .9093, .9218, .9281, .9265, .9080, .8598, .7721, .6297, .4089],
[.8743, .8957, .9130, .9253, .9316, .9304, .9131, .8678, .7858, .6538, .4519],
[.8836, .9026, .9179, .9287, .9342, .9331, .9183, .8804, .8128, .7065, .5485],
[.8943, .9103, .9230, .9319, .9362, .9351, .9231, .8930, .8406, .7602, .6442],
[.9060, .9169, .9253, .9310, .9334, .9321, .9236, .9036, .8703, .8211, .7529],
[.9170, .9224, .9264, .9288, .9293, .9280, .9231, .9127, .8962, .8730, .8423],
[.9159, .9171, .9176, .9177, .9171, .9159, .9136, .9097, .9042, .8968, .8876],
[.9061, .9059, .9055, .9052, .9047, .9042, .9036, .9028, .9018, .9007, .8994],
[.8962, .8964, .8965, .8966, .8967, .8968, .8969, .8970, .8971, .8972, .8973]],
[[.8070, .8291, .8461, .8566, .8586, .8497, .8170, .7410, .6022, .3674, .0714],
[.8230, .8454, .8628, .8741, .8775, .8708, .8419, .7732, .6477, .4372, .0916],
[.8411, .8631, .8805, .8921, .8966, .8918, .8671, .8065, .6959, .5124, .2168],
[.8565, .8783, .8957, .9077, .9131, .9099, .8883, .8338, .7340, .5696, .3083],
[.8662, .8879, .9055, .9179, .9239, .9219, .9024, .8520, .7600, .6096, .3739],
[.8699, .8917, .9093, .9218, .9281, .9265, .9080, .8598, .7721, .6297, .4089],
[.8743, .8957, .9130, .9253, .9316, .9304, .9131, .8678, .7858, .6538, .4519],
[.8836, .9026, .9179, .9287, .9342, .9331, .9183, .8804, .8128, .7065, .5485],
[.8943, .9103, .9230, .9319, .9362, .9351, .9231, .8930, .8406, .7602, .6442],
[.9060, .9169, .9253, .9310, .9334, .9321, .9236, .9036, .8703, .8211, .7529],
[.9170, .9224, .9264, .9288, .9293, .9280, .9231, .9127, .8962, .8730, .8423],
[.9159, .9171, .9176, .9177, .9171, .9159, .9136, .9097, .9042, .8968, .8876],
[.9061, .9059, .9055, .9052, .9047, .9042, .9036, .9028, .9018, .9007, .8994],
[.8962, .8964, .8965, .8966, .8967, .8968, .8969, .8970, .8971, .8972, .8973]]])
PRmap = np.array([[[1.0678, 1.0649, 1.0613, 1.0571, 1.0522, 1.0468, 1.0402, 1.0322, 1.0227, 1.0117, 1.0000],
[1.1239, 1.1186, 1.1122, 1.1047, 1.0962, 1.0865, 1.0751, 1.0611, 1.0445, 1.0257, 1.0045],
[1.1994, 1.1910, 1.1809, 1.1691, 1.1558, 1.1409, 1.1233, 1.1020, 1.0771, 1.0488, 1.0173],
[1.2981, 1.2855, 1.2706, 1.2533, 1.2339, 1.2122, 1.1869, 1.1563, 1.1210, 1.0811, 1.0370],
[1.4289, 1.4111, 1.3899, 1.3655, 1.3380, 1.3076, 1.2720, 1.2295, 1.1804, 1.1254, 1.0654],
[1.5118, 1.4909, 1.4661, 1.4375, 1.4052, 1.3695, 1.3278, 1.2779, 1.2205, 1.1565, 1.0868],
[1.6070, 1.5827, 1.5538, 1.5205, 1.4831, 1.4417, 1.3934, 1.3358, 1.2697, 1.1962, 1.1165],
[1.7160, 1.6881, 1.6555, 1.6183, 1.5767, 1.5312, 1.4785, 1.4160, 1.3448, 1.2660, 1.1808],
[1.8402, 1.8086, 1.7724, 1.7318, 1.6869, 1.6381, 1.5824, 1.5170, 1.4430, 1.3615, 1.2736],
[1.9930, 1.9587, 1.9206, 1.8788, 1.8336, 1.7852, 1.7309, 1.6685, 1.5988, 1.5225, 1.4405],
[2.1593, 2.1257, 2.0899, 2.0518, 2.0117, 1.9695, 1.9235, 1.8724, 1.8163, 1.7557, 1.6909],
[2.2764, 2.2510, 2.2248, 2.1978, 2.1701, 2.1416, 2.1118, 2.0801, 2.0464, 2.0108, 1.9735],
[2.3771, 2.3664, 2.3557, 2.3448, 2.3339, 2.3229, 2.3118, 2.3004, 2.2887, 2.2768, 2.2646],
[2.4559, 2.4538, 2.4516, 2.4495, 2.4473, 2.4452, 2.443, 2.4409, 2.4387, 2.4365, 2.4343]],
[[1.0678, 1.0649, 1.0613, 1.0571, 1.0522, 1.0468, 1.0402, 1.0322, 1.0227, 1.0117, 1.0000],
[1.1239, 1.1186, 1.1122, 1.1047, 1.0962, 1.0865, 1.0751, 1.0611, 1.0445, 1.0257, 1.0045],
[1.1994, 1.1910, 1.1809, 1.1691, 1.1558, 1.1409, 1.1233, 1.1020, 1.0771, 1.0488, 1.0173],
[1.2981, 1.2855, 1.2706, 1.2533, 1.2339, 1.2122, 1.1869, 1.1563, 1.1210, 1.0811, 1.0370],
[1.4289, 1.4111, 1.3899, 1.3655, 1.3380, 1.3076, 1.2720, 1.2295, 1.1804, 1.1254, 1.0654],
[1.5118, 1.4909, 1.4661, 1.4375, 1.4052, 1.3695, 1.3278, 1.2779, 1.2205, 1.1565, 1.0868],
[1.6070, 1.5827, 1.5538, 1.5205, 1.4831, 1.4417, 1.3934, 1.3358, 1.2697, 1.1962, 1.1165],
[1.7160, 1.6881, 1.6555, 1.6183, 1.5767, 1.5312, 1.4785, 1.4160, 1.3448, 1.2660, 1.1808],
[1.8402, 1.8086, 1.7724, 1.7318, 1.6869, 1.6381, 1.5824, 1.5170, 1.4430, 1.3615, 1.2736],
[1.9930, 1.9587, 1.9206, 1.8788, 1.8336, 1.7852, 1.7309, 1.6685, 1.5988, 1.5225, 1.4405],
[2.1593, 2.1257, 2.0899, 2.0518, 2.0117, 1.9695, 1.9235, 1.8724, 1.8163, 1.7557, 1.6909],
[2.2764, 2.2510, 2.2248, 2.1978, 2.1701, 2.1416, 2.1118, 2.0801, 2.0464, 2.0108, 1.9735],
[2.3771, 2.3664, 2.3557, 2.3448, 2.3339, 2.3229, 2.3118, 2.3004, 2.2887, 2.2768, 2.2646],
[2.4343, 2.4365, 2.4387, 2.4409, 2.4430, 2.4452, 2.4473, 2.4495, 2.4516, 2.4538, 2.4559]]])
label = []
for x in NcMap:
label.append(x*100)
for i in range(0,14):
plt.annotate('{0}%'.format(round(label[i],2)),xy = ((flowmax[i],PRmax[i])), textcoords='offset points', xytext=(0,6), ha = 'center', color = 'b')
plt.xlim(0,1)
plt.ylim(1,8)
plt.ylabel(r'$PR_{off}$', fontsize=16)
plt.xlabel(r'$\.m_{c,off} [kg/s]$', fontsize=16)
x = WCmap[0,:14,:]
x = x.flatten().tolist()
y = PRmap[0,:14,:]
y = y.flatten().tolist()
z = effMap[0,:14,:]
z = z.flatten().tolist()
plt.tricontourf(x,y,z, cmap = 'jet')
cbar = plt.colorbar()
cbar.set_label(r'$\eta_{off}$', fontsize=16)
plt.show()
Compressor Map Plot

Categories

Resources