小编Don*_*ong的帖子

How to get matplotlib and latex work together?

I have the following problem and I am totally new to matplotlib and python: To produce high qualitiy plots for my thesis I want to use matplotlib and I want to use the latex commands for the axes etc. When I try the following example (from http://matplotlib.org/users/usetex.html#usetex-tutorial):

import numpy as np 
import matplotlib.pyplot as plt


# Example data 
t = np.arange(0.0, 1.0 + 0.01, 0.01) 
s = np.cos(4 * np.pi * t) + 2

plt.rc('text', usetex=True) 
plt.rc('font', family='serif') 
plt.plot(t, …
Run Code Online (Sandbox Code Playgroud)

python plot latex matplotlib tex

5
推荐指数
1
解决办法
6181
查看次数

如何使用matplotlib定义具有绝对值的colormap

我使用以下脚本进行绘图:

import matplotlib

import matplotlib.pyplot as plt
import numpy as np
import pylab as pl
import math
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator
from matplotlib.colors import LinearSegmentedColormap

cdict1 = {'red':   ((0.0, 1.0, 1.0),
                   (0.4, 1.0, 1.0),
                   (0.7, 0.0, 0.0),
                   (1.0, 0.0, 0.0)),

         'green': ((0.0, 1.0, 1.0),
                   (0.1, 0.0, 0.0),
                   (1.0, 0.0, 0.0)),

         'blue':   ((0.0, 1.0, 1.0),
                   (0.1, 0.0, 0.0),
                   (0.4, 0.0, 0.0),
                   (1.0, 1.0, 1.0))
        }

white_blue_red = LinearSegmentedColormap('WhiteBlueRed', cdict1)
plt.register_cmap(cmap=white_blue_red)

x = np.loadtxt('data.dat',
                 unpack=True)

plt.scatter(x[0], x[1], marker='.', …
Run Code Online (Sandbox Code Playgroud)

python plot matplotlib absolute-value colormap

5
推荐指数
1
解决办法
4166
查看次数

标签 统计

matplotlib ×2

plot ×2

python ×2

absolute-value ×1

colormap ×1

latex ×1

tex ×1