首页 > 其他分享 >习题3.3

习题3.3

时间:2024-10-22 12:59:31浏览次数:5  
标签:plt rcParams 3.3 import np ax 习题

习题3.3代码

import numpy as np
import pandas as pd
import sympy as sp
sp.init_printing(use_unicode=True)
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='cm'

Times New Roman + SimSun + WFM Sans SC

simsum宋体, times new roman -*, simhei黑体, kaiti楷体,

dengxian等线, fangsong仿宋, Microsoft Yahei微软雅黑

plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200

plt.rcParams['figure.figsize'] = [4, 3]

plt.rcParams['font.size'] = 12

plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
from scipy.sparse.linalg import eigs
L = np.array([[0, 1, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1],
[1, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 1],
[0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 0]])
r = np.sum(L, axis=1, keepdims=True)
P = L/r
d = 0.85
Ptilde = (1-d)/len(P)np.ones_like(P) + dP
val, vec = eigs(Ptilde.T, 1)
V = vec.flatten()
V = V.real
V /= sum(V)
print(V)
fig, ax = plt.subplots()
ax.bar(range(1, len(V)+1), V, width=0.6)
ax.set_xlabel('Page')
ax.set_ylabel('Rank')
fig.show()、

标签:plt,rcParams,3.3,import,np,ax,习题
From: https://www.cnblogs.com/DENWOSHUABAZONGSHI/p/18492421

相关文章

  • 习题2.13
    习题2.13代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtex......
  • 习题2.12
    习题2.12代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtex......
  • 习题4.3
    习题4.3代码importcvxpyascpimportnumpyasnpimportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext.fontset']='stix'TimesNewRoman+SimS......
  • 习题5.7
    习题5.7代码importcvxpyimportcvxpyascpimportnumpyasnpimportpandasaspdfromscipy.optimizeimportminimizeimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltx=cp.Variable(3,integer=True)cumulative_output=c......
  • 习题6.3
    习题6.3代码importnumpyasnpimportpandasaspdimportcvxpyascpimportnetworkxasnximportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext.fontset'......
  • 习题6.4
    习题6.4代码importnumpyasnpimportpandasaspdimportcvxpyascpimportnetworkxasnximportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext.fontset'......
  • 习题6.1
    习题6.1代码importnumpyasnpimportpandasaspdimportcvxpyascpimportnetworkxasnximportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext.fontset'......
  • python第五章课后习题
    importnumpyasnpimportmathfromscipy.optimizeimportminimize,Boundsdeffunc(x):returnsum(math.sqrt(x[i])foriinrange(100))defcon(x):return1000-np.sum(x[i]*(101-i+1)foriinrange(100))con1={'type':'ineq','fun&#......
  • 习题6.7代码
    习题6.7代码importnumpyasnpimportpandasaspdimportcvxpyascpimportnetworkxasnximportmatplotlib.pyplotaspltdf=pd.read_excel('F:\python数学建模与算法\源程序\《Python数学建模算法与应用》程序和数据\第6章图论模型\data6.xlsx')D=df.valuesdo......
  • 刷c语言练习题9(牛客网)
    1、12345678char*getmemory(void){    charp[]= "helloworld";    returnp;}voidtest(void){    char*str=NULL;    str=getmemory(); printf(str);}请问运行Test函数会有什么样的结果?A、出错B、输出"helloworld"C、输出空......