Matplotlib - 改变用作绘图背景的图像的不透明度

时间:2016-10-20 22:28:50

标签: python matplotlib

我使用matplotlib为绘图设置图像背景。但曲线的颜色在某些地方与背景混合在一起。任何人都可以帮我减少背景的不透明度,以便实际的情节更加明显。我的代码到此为止 -

string authenticity_token = string.Empty;
// get auth token
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://twitter.com/login");
    //request.Proxy = null;
    request.Proxy = WebProxy;
    request.Timeout = Timeout.Infinite;
    request.ReadWriteTimeout = Timeout.Infinite;
    request.KeepAlive = false;
    request.AllowAutoRedirect = false; // was true
    request.CookieContainer = cc;
    request.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    string SourceCode = new StreamReader(response.GetResponseStream()).ReadToEnd();

    authenticity_token = Regex.Match(SourceCode, "name=\"authenticity_token\" value=\".*?\"").Value.Replace("name=\"authenticity_token\" value=", "").Replace("\"", "");
}
// login
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://twitter.com/sessions");
    //request.Proxy = null;
    request.Proxy = WebProxy;
    request.Timeout = 10000;
    request.ReadWriteTimeout = 10000;
    request.KeepAlive = false;
    request.AllowAutoRedirect = false; // was true
    request.CookieContainer = cc;
    request.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36";
    request.Method = "POST";
    string log= "/";
    string post_data = string.Format("session%5Busername_or_email%5D={0}&session%5Bpassword%5D={1}&authenticity_token={2}&scribe_log=&redirect_after_login={3}&remember_me=1", email, password, authenticity_token, log);
    byte[] array = Encoding.UTF8.GetBytes(post_data);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = array.Length;
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(array, 0, array.Length);
    dataStream.Close();
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}

// go to account settings and extract the username from the input box
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://twitter.com/settings/account");
    //request.Proxy = null;
    request.Proxy = WebProxy;
    request.Timeout = 10000;
    request.ReadWriteTimeout = 10000;
    request.KeepAlive = false;
    request.AllowAutoRedirect = false; // was true
    request.CookieContainer = cc;
    //request.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36";
    request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    string reader = new StreamReader(response.GetResponseStream()).ReadToEnd();

    username = Regex.Match(Regex.Match(reader, "<input id=\"user_screen_name\".*?value=\".*?\">").Value, "value=\".*?\"").Value.Replace("value=", "").Replace("\"", "");
}

enter image description here

1 个答案:

答案 0 :(得分:0)

你有没有试过像:

plt.imshow(img, zorder=0,  extent=[0.1, 30.0, -10.0, 10.0], alpha = 0.6)