2016-10-20 6 views
0

matplotlibを使用して、プロットの画像背景を設定しました。しかし、いくつかの場所では、カーブの色が背景と混ざってしまいます。誰でも私が背景の不透明度を下げるのを助けることができるので、実際のプロットがより見えるようになります。この時点までの私のコードがある -Matplotlib - プロットの背景として使用される画像の不透明度を変更する

import pandas as pd 
import sys, os 
import matplotlib.pyplot as plt 
import numpy as np 
import itertools 
from scipy.misc import imread 

def flip(items, ncol): 
    return itertools.chain(*[items[i::ncol] for i in range(ncol)]) 

df = pd.read_pickle('neer.pickle') 
rows = list(df.index) 
countries = ['USA','CHN','JPN','DEU','GBR','FRA','IND','ITA','BRA','CAN','RUS'] 
x = range(len(rows)) 
df = df.pct_change() 

fig, ax = plt.subplots(1) 
for country in countries: 
    ax.plot(x, df[country], label=country) 

plt.xticks(x, rows, size='small', rotation=75) 
#legend = ax.legend(loc='upper left', shadow=True) 
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) 
plt.show(1) 

df1 = df[countries] 
plt.figure(2) 
for country in countries: 
    my_plot = plt.plot(x, 10*df[country], label=country) 
img = imread("world.png") 
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) 
plt.imshow(img,zorder=0, extent=[0.1, 30.0, -10.0, 10.0]) 
plt.set_alpha(0.5) 
plt.title('Variation of NEER across the world') 
plt.show(2) 

enter image description here

答えて

0

は、あなたのような何かを試してみました:

plt.imshow(img, zorder=0, extent=[0.1, 30.0, -10.0, 10.0], alpha = 0.6) 
関連する問題