Menu
Woocommerce Menu

matplotlib学习之函数积分图,自制简易打赏功能的实例

0 Comment

matplotlib学习之函数积分图,matplotlib函数积分

# coding:utf-8

import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Polygon

'''
求函数积分
'''


def func(x):
    return -(x - 2) * (x - 8) + 40


print(plt.style.available)
plt.style.use("ggplot")

# 绘制曲线
x = np.linspace(0, 10)
y = func(x)
fig, ax = plt.subplots()
plt.plot(x, y, linewidth=2)

# 设置坐标轴
a = 2
b = 9
ax.set_xticks([a, b])  # 设置横坐标2,9
ax.set_yticks([])  # 设置纵坐标为空
ax.set_xticklabels(['$a$', '$b$'])  # 设置横坐标显示为a,b
plt.figtext(0.91, 0.09, '$x$')  # 设置坐标轴字母
plt.figtext(0.11, 0.88, '$y$')

# 确定多边形
ix = np.linspace(a, b)
iy = func(ix)
ixy = zip(ix, iy)
verts = [(a, 0)] + list(ixy) + [(b, 0)]
poly = Polygon(verts, facecolor='0.9', edgecolor='0.5')
ax.add_patch(poly)

# 添加数学公式
x_math = (a + b) * 0.5
y_math = 35
plt.text(x_math, y_math, r'$\int_a^b(-(x - 2) * (x - 8) + 40)$', fontsize=13, horizontalalignment='center')

plt.title('functional integration')
plt.show()

图片 1

 

#
coding:utf-8 import numpy as np from matplotlib import pyplot as plt
from matplotlib.patches import Polygon ”’ 求函数…

自制简易打赏效率的实例,自制实例

1、申请开通cnblogs的JS代码协助

图片 2

2、将微信收款码图片上传到cnblogs

图片 3

3、将如下代码中的轮番为刚刚上传的收款码图片的链接地址,然后将代码增添到设置->博客左边栏文告(支持HTML代码)**(支持JS代码)里面,再点击“保存**”即可。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html;" />
  <title>打赏</title>
  <style type="text/css">
    #dsSidebar {
      z-index: 999999;
      top: 18%;
      width: 200px;
      height: 200px;
      position: fixed;
      right: -200px;
    }

    #dsBtn {
      z-index: 999999;
      width: 30px;
      height: 58px;
      left: -30px;
      top: 80px;
      line-height: 28px;
      position: absolute;
    }

    .dsPanels {
      margin: 0px auto;
      overflow: hidden;
    }

    .dsPanel {
      float: left;
      margin: 0px 0px;
      padding: 12px 0px;
      text-align: center;
      background: #ffeedd;
      border-color: #ffeedd;
      border-radius: 8px;
    }

    .dsPanel-highlight {
      margin-top: 0;
      margin-bottom: 0;
      padding-left: 10px;
      padding-right: 10px;
      width: 160px;
      border: 8px solid #fd935c;
    }

    .dsPanel-button {
      display: block;
      font-size: 16px;
      font-weight: 500;
      color: #ffeedd;
      text-align: center;
      text-decoration: none;
      text-shadow: 0 1px rgba(black, .1);
      background: #fd935c;
      border-bottom: 2px solid #cf7e3b;
      border-color: rgba(black, .15);
      border-radius: 4px;
    }

    .dsPanel-title {
      width: 128px;
      margin: -15px auto 15px;
      padding-bottom: 0px;
      line-height: 22px;
      font-size: 14px;
      font-weight: bold;
      color: #ffeedd;
      text-shadow: 0 1px rgba(black, .05);
      background: #fd935c;
      border-radius: 0 0 4px 4px;
    }
  </style>
  <script>
    function moveBtn() {
      var dsBtn = document.getElementById("dsBtn");
      var now = new Date();
      var times = now.getTime();
      var offsetSize = Math.sin(times / 380.0) * 15 + 45;
      var radius = Math.sin(times / 380.0) * 18 + 24;
      dsBtn.style.left = -offsetSize + 'px';
      dsBtn.style.width = offsetSize + 'px';
      dsBtn.style.borderRadius = radius + 'px';
      setTimeout(moveBtn, 60);
    }

    var dsSidebarTimer = null;
    var dsSidebarOffsetRight = -200;
    function startMove(dsSidebarTarget, dsSidebarSpeed) {
      clearTimeout(dsSidebarTimer);
      function doMove() {
        var dsSidebar = document.getElementById('dsSidebar');
        dsSidebarSpeed *= 0.9;
        if (dsSidebarSpeed > -1 && dsSidebarSpeed < 0) {
          dsSidebarSpeed = -1;
        } else if (dsSidebarSpeed < 1 && dsSidebarSpeed > 0) {
          dsSidebarSpeed = 1;
        }
        dsSidebarOffsetRight = dsSidebarOffsetRight + dsSidebarSpeed;
        if (dsSidebarSpeed > 0 && dsSidebarOffsetRight >= dsSidebarTarget) {
          dsSidebarOffsetRight = dsSidebarTarget;
          dsSidebar.style.right = dsSidebarOffsetRight + 'px';
        } else if (dsSidebarSpeed < 0 && dsSidebarOffsetRight <= dsSidebarTarget) {
          dsSidebarOffsetRight = dsSidebarTarget;
          dsSidebar.style.right = dsSidebarOffsetRight + 'px';
        } else {
          dsSidebar.style.right = dsSidebarOffsetRight + 'px';
          dsSidebarTimer = setTimeout(doMove, 30);
        }
      }
      doMove();
    }
    document.getElementById('dsImg').onload = function () {
      var dsSidebar = document.getElementById('dsSidebar');
      dsSidebar.onmouseover = function () {
        startMove(0, 24);
      }
      dsSidebar.onmouseout = function () {
        startMove(-200, -24);
      }
      moveBtn();
    }
  </script>
</head>

<body>
  <div id="dsSidebar">
    <div class="dsPanels">
      <div class="dsPanel dsPanel-highlight">
        <p class="dsPanel-title">喜欢请用微信打赏</p>
        <img id='dsImg' src="http://files.cnblogs.com/files/eritpang/weixin.bmp" alt="图片 4" width="160" height="160" />
      </div>
    </div>
    <b>打<br/>赏</b>
  </div>
</body>

</html>

4、效果如下。

图片 5

上述那篇自制简易打赏作用的实例正是笔者分享给我们的全部内容了,希望能给我们一个参阅,也期望大家多多点拨帮客之家。

1、申请开展cnblogs的JS代码扶助 2、将Wechat收款码图片上传到cnblogs 3、
将如下代码中的 …

CSS3七个自适应关键字——fill-available、max-content、min-content、fit-content,css3fill-available

前面的话

  经常地,有两种自适应:撑满空闲空间与降到内容尺寸。CSS3将那二种景况分别定义为’fill-availabel’和’fit-content’。除了这些之外 ,还新扩张了更加细粒度的’min-content’和’max-content’。那多少个重视字可用以安装宽高属性。本文将详细介绍CSS3中的那七个自适应关键字

  [注意]IE浏览器不帮忙,webkit内核浏览器需加上-webkit-前缀

 

标签:,

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章

网站地图xml地图