matplotlib

how to find values within a radius from a central position of latitude and longitude value

这一生的挚爱 提交于 2021-02-08 11:16:28
问题 I am trying to calculate all the values contained within a particular radius from a central lat lon position.The code which I am using is as given: import numpy as np import matplotlib.pylab as pl import netCDF4 as nc import haversine f = nc.Dataset('air_temp.nc') def haversine(lon1, lat1, lon2, lat2): # convert decimal degrees to radians lon1 = np.deg2rad(lon1) lon2 = np.deg2rad(lon2) lat1 = np.deg2rad(lat1) lat2 = np.deg2rad(lat2) # haversine formula dlon = lon2 - lon1 dlat = lat2 - lat1 a

how to find values within a radius from a central position of latitude and longitude value

家住魔仙堡 提交于 2021-02-08 11:16:05
问题 I am trying to calculate all the values contained within a particular radius from a central lat lon position.The code which I am using is as given: import numpy as np import matplotlib.pylab as pl import netCDF4 as nc import haversine f = nc.Dataset('air_temp.nc') def haversine(lon1, lat1, lon2, lat2): # convert decimal degrees to radians lon1 = np.deg2rad(lon1) lon2 = np.deg2rad(lon2) lat1 = np.deg2rad(lat1) lat2 = np.deg2rad(lat2) # haversine formula dlon = lon2 - lon1 dlat = lat2 - lat1 a

Mouse Hover in matplotlib candlestick for python

纵然是瞬间 提交于 2021-02-08 10:55:39
问题 I have implemented this example: http://matplotlib.sourceforge.net/examples/pylab_examples/finance_demo.html?highlight=candlestick I would like to implement mouse hover features for the candlestick so that I can see the candlestick's open/high/low/close either in a popup or a label in a certain panel. I was following along with: http://matplotlib.sourceforge.net/examples/event_handling/pick_event_demo.html Unfortunately, the function: candlestick(ax, quotes, width=0.6) does not have a picker

Python: Embed a matplotlib plot with slider in tkinter properly

佐手、 提交于 2021-02-08 10:55:34
问题 I have created this plot in pyplot which has a slider to view a certain range of the data. import random import matplotlib import tkinter as Tk import matplotlib.pyplot as plt from matplotlib.widgets import Slider from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg fig, ax = plt.subplots() plt.subplots_adjust(bottom=0.25) y_values = [random.randrange(20, 40, 1) for _ in range(40)] x_values = [i for i in range(40)] l, = plt.plot(x_values, y_values) plt.axis([0, 9, 20, 40]) ax_time

Mouse Hover in matplotlib candlestick for python

守給你的承諾、 提交于 2021-02-08 10:55:04
问题 I have implemented this example: http://matplotlib.sourceforge.net/examples/pylab_examples/finance_demo.html?highlight=candlestick I would like to implement mouse hover features for the candlestick so that I can see the candlestick's open/high/low/close either in a popup or a label in a certain panel. I was following along with: http://matplotlib.sourceforge.net/examples/event_handling/pick_event_demo.html Unfortunately, the function: candlestick(ax, quotes, width=0.6) does not have a picker

Python: Embed a matplotlib plot with slider in tkinter properly

…衆ロ難τιáo~ 提交于 2021-02-08 10:54:27
问题 I have created this plot in pyplot which has a slider to view a certain range of the data. import random import matplotlib import tkinter as Tk import matplotlib.pyplot as plt from matplotlib.widgets import Slider from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg fig, ax = plt.subplots() plt.subplots_adjust(bottom=0.25) y_values = [random.randrange(20, 40, 1) for _ in range(40)] x_values = [i for i in range(40)] l, = plt.plot(x_values, y_values) plt.axis([0, 9, 20, 40]) ax_time

Python: Embed a matplotlib plot with slider in tkinter properly

旧巷老猫 提交于 2021-02-08 10:54:21
问题 I have created this plot in pyplot which has a slider to view a certain range of the data. import random import matplotlib import tkinter as Tk import matplotlib.pyplot as plt from matplotlib.widgets import Slider from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg fig, ax = plt.subplots() plt.subplots_adjust(bottom=0.25) y_values = [random.randrange(20, 40, 1) for _ in range(40)] x_values = [i for i in range(40)] l, = plt.plot(x_values, y_values) plt.axis([0, 9, 20, 40]) ax_time

Latex \phantom not creating whitespace in matplotlib

我们两清 提交于 2021-02-08 10:44:20
问题 Friends, I have 71 ticks that I need to put on a plot (it's the sequence of a protein) and so the ticks need to be staggered, and some are highlighted with asterisks: ________________________________ P o A i I A o g e u n e f e t r l t x s s L n S q e c O L t e s * * * ** * * * I'm using matplotlib.rc('text', usetex=True) so that I can move the asterisks up (they appear too far down on the axis unless I decrease their \vspace ) The problem is that the staggering doesn't work, any attempts to

Matplotlib fill_between edge effect with `where` argument

六眼飞鱼酱① 提交于 2021-02-08 10:30:45
问题 I want to plot the region between two curves with different colors whether one of the line is positive or negative. I got edge effect with non-continuous coloring of the region when the curve changes of sign. Setting interpolate=True does not really help. The edge effect is related to the resolution (voluntarily coarse in the basic example below) - enhancing it is not really what I want. Any better solution to make smooth transitions? Thanks. import matplotlib.pyplot as plt import numpy plt

Set Xticks frequency to dataframe index

若如初见. 提交于 2021-02-08 10:21:16
问题 I currently have a dataframe that has as an index the years from 1990 to 2014 (25 rows). I want my plot to have the X axis with all the years showing. I'm using add_subplot as I plan to have 4 plots in this figure (all of them with the same X axis). To create the dataframe: import pandas as pd import numpy as np index = np.arange(1990,2015,1) columns = ['Total Population','Urban Population'] pop_plot = pd.DataFrame(index=index, columns=columns) pop_plot = df_.fillna(0) pop_plot['Total