Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mplleaflet not showing plot . #66

Open
sameerCoder opened this issue Jun 4, 2019 · 0 comments
Open

Mplleaflet not showing plot . #66

sameerCoder opened this issue Jun 4, 2019 · 0 comments

Comments

@sameerCoder
Copy link

Hi,
I have tripcolor trianulation plot wave plot and that plot i need to overlap with background as google map with zoom function , so i tried mplleaflet but the tripcolor plot is not coming over the map.
can you tell me how to do this.

%matplotlib inline
import matplotlib.pyplot as plt
from scipy.io import loadmat
import mplleaflet
import datetime
import pandas as pd
from dateutil.parser import parse

import matplotlib as mpl

from pylab import *

import numpy as np
import os

#fig=plt.figure()
#fig, ax = plt.subplots(figsize=(13, 13), subplot_kw=dict(projection=projection))

os.environ['PROJ_LIB'] = r'C:\Users\walps\Anaconda3\pkgs\proj4-5.2.0-ha925a31_1\Library\share'

from datetime import timedelta

import matplotlib.tri as mtri
datamat = loadmat('IOEC_ECM2017_BC.mat')
Xp = datamat['Xp']
Yp = datamat['Yp']
strt = datetime.datetime(2017, 1, 11, 0, 0)
end = datetime.datetime(2017, 1, 21, 0, 0)
numdays = 3

def perdelta(strt, end, delta):
curr = strt
while curr < end:
yield curr
curr += delta

Read element file

data = pd.read_table('fort.ele',delim_whitespace=True,names=('A','B','C','D'))

tri_new = pd.read_csv('fort.ele', delim_whitespace=True, names=('A', 'B', 'C', 'D'), usecols=[1, 2, 3], skiprows=1,
dtype={'D': np.int})

data1=data[['B','C','D']]

tri=data1[1:]

dateList = []
for result in perdelta(strt, strt + timedelta(days=2), timedelta(hours=3)):
dat = result
# print(result)
dt = parse(str(dat))
yr = dt.year
mn = dt.month
d = dt.day
hr = dt.hour
mi = dt.minute
# print(y,mn,d,hr,mi)
if hr < 10:
# d='0'+str(d)
hr = '0' + str(hr)
else:
d = str(d)
hr = str(hr)
if int(d) < 10:
d = '0' + str(d)
else:
d = str(d)
varname = 'Hsig_' + str(yr) + '0' + str(mn) + str(d) + '_' + hr + '0000'
print(varname)

x = Xp.flatten()
y = Yp.flatten()
z = datamat[varname]
z1 = z.flatten()

tri_sub = tri_new.apply(lambda x: x - 1)
triang = mtri.Triangulation(x, y, triangles=tri_sub)

#pp = plt.tripcolor(triang, z1, cmap='jet', vmin=0.0, vmax="0.5")
#pp = plt.tripcolor(triang, z1,cmap='jet')
# ax.tripcolor()
#     #
#     # plt.suptitle('Significant Wave Height', fontname='Comic Sans MS', fontweight='bold', fontsize=12, color="red")
#     # plt.title("Experimental forecast for " + str(hr) + ':' + '0' + str(mi) + ' ' + str(d) + '-' + 'Jan' + '-' + str(yr),
#     #           fontsize=10, fontname='sans-serif', color="green")
#     #
#     # plt.savefig(varname + '.png', dpi=500)

# plt.colorbar()
#plt.show()
#mplleaflet.show()
fig, ax = plt.subplots()
tp=ax.tripcolor(triang, z1, vmin=0, vmax=2)
#mplleaflet.display(fig=tp)
mplleaflet.display()
mplleaflet.show()
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant