matplotlib

Add datashader image to matplotlib subplots

跟風遠走 提交于 2021-01-22 09:39:22
问题 Is it possible to add a datashader image to a set of matplotlib subplots? As a concrete example, import numpy as np import pandas as pd import matplotlib.pylab as plt import datashader as ds import datashader.transfer_functions as tf from datashader.utils import export_image from functools import partial background = "white" export = partial(export_image, background = background, export_path="export") N = 10000 df = pd.DataFrame(np.random.random((N, 3)), columns = ['x','y', 'z']) f, ax = plt

Set Colorbar range with “contourf” in matplotlib

牧云@^-^@ 提交于 2021-01-22 05:19:07
问题 How to reduce the colorbar limit when used with contourf ? The color bound from the graphs itself are well set with "vmin" and "vmax", but the colorbar bounds are not modified. import numpy as np import matplotlib.pyplot as plt x = np.arange(20) y = np.arange(20) data = x[:,None]+y[None,:] X,Y = np.meshgrid(x,y) vmin = 0 vmax = 15 #My attempt fig,ax = plt.subplots() contourf_ = ax.contourf(X,Y,data, 400, vmin=vmin, vmax=vmax) cbar = fig.colorbar(contourf_) cbar.set_clim( vmin, vmax ) # With

Plot datetime.time in seaborn

最后都变了- 提交于 2021-01-22 04:25:27
问题 Hi I am having trouble plotting a datetime with seaborn. I am trying to plot a categorical data with x as datatype datetime.time but I get these error: float() argument must be a string or a number, not 'datetime.time' This is my df: toronto_time description 0 00:00:50 STATS 1 00:01:55 STATS 2 00:02:18 ONLINE 3 00:05:24 STATS 4 00:05:34 STATS 5 00:06:33 OFFLINE This is my code: import matplotlib.pyplot as plt import seaborn as sns plt.style.use('seaborn-colorblind') plt.figure(figsize=(8,6))

Remove white border when using subplot and imshow in python (Matplotlib)

邮差的信 提交于 2021-01-22 04:24:59
问题 import numpy as np import sys import matplotlib as mpl import matplotlib.pyplot as plt i use the following code to save an image fig, ax = plt.subplots(frameon=False) ax.axis ('off') ax.imshow (array[:,:,0,0,0]) fig.savefig ("file.png", bbox_inches='tight') However, what I get is and this obviously still has a white border. How do I get rid of it? The array.shape is: (256, 256, 1, 1, 3) 回答1: Look at my example it may help you: import numpy as np import matplotlib.pyplot as plt def save_image

Plot datetime.time in seaborn

五迷三道 提交于 2021-01-22 04:24:47
问题 Hi I am having trouble plotting a datetime with seaborn. I am trying to plot a categorical data with x as datatype datetime.time but I get these error: float() argument must be a string or a number, not 'datetime.time' This is my df: toronto_time description 0 00:00:50 STATS 1 00:01:55 STATS 2 00:02:18 ONLINE 3 00:05:24 STATS 4 00:05:34 STATS 5 00:06:33 OFFLINE This is my code: import matplotlib.pyplot as plt import seaborn as sns plt.style.use('seaborn-colorblind') plt.figure(figsize=(8,6))

Plot datetime.time in seaborn

风流意气都作罢 提交于 2021-01-22 04:24:45
问题 Hi I am having trouble plotting a datetime with seaborn. I am trying to plot a categorical data with x as datatype datetime.time but I get these error: float() argument must be a string or a number, not 'datetime.time' This is my df: toronto_time description 0 00:00:50 STATS 1 00:01:55 STATS 2 00:02:18 ONLINE 3 00:05:24 STATS 4 00:05:34 STATS 5 00:06:33 OFFLINE This is my code: import matplotlib.pyplot as plt import seaborn as sns plt.style.use('seaborn-colorblind') plt.figure(figsize=(8,6))

pip install matplotlib: “no pkg-config”

耗尽温柔 提交于 2021-01-21 13:35:31
问题 When I run pip install matplotlib (within a virtualenv), the first lines of output are: Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local'] ============================================================================ BUILDING MATPLOTLIB matplotlib: 1.2.0 python: 2.7.3 (default, Dec 14 2012, 13:31:05) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] platform: darwin REQUIRED DEPENDENCIES numpy: 1.6.2

pip install matplotlib: “no pkg-config”

老子叫甜甜 提交于 2021-01-21 13:35:09
问题 When I run pip install matplotlib (within a virtualenv), the first lines of output are: Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local'] ============================================================================ BUILDING MATPLOTLIB matplotlib: 1.2.0 python: 2.7.3 (default, Dec 14 2012, 13:31:05) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] platform: darwin REQUIRED DEPENDENCIES numpy: 1.6.2

pip install matplotlib: “no pkg-config”

亡梦爱人 提交于 2021-01-21 13:33:14
问题 When I run pip install matplotlib (within a virtualenv), the first lines of output are: Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local'] ============================================================================ BUILDING MATPLOTLIB matplotlib: 1.2.0 python: 2.7.3 (default, Dec 14 2012, 13:31:05) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] platform: darwin REQUIRED DEPENDENCIES numpy: 1.6.2

Python - Plot Multiple Dataframes by Month and Day (Ignore Year)

不羁的心 提交于 2021-01-21 09:29:06
问题 I have multiple dataframes having different years data. The data in dataframes are: >>> its[0].head(5) Crocs date 2017-01-01 46 2017-01-08 45 2017-01-15 43 2017-01-22 43 2017-01-29 41 >>> its[1].head(5) Crocs date 2018-01-07 23 2018-01-14 21 2018-01-21 23 2018-01-28 21 2018-02-04 25 >>> its[2].head(5) Crocs date 2019-01-06 90 2019-01-13 79 2019-01-20 82 2019-01-27 82 2019-02-03 81 I tried to plot all these dataframes in single figure (graph), yeah i accomplished but it was not what i wanted.