#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate
from matplotlib import colors, ticker, cm
from matplotlib.colors import LogNorm
N = 100 #number of points for plotting/interpolation
y, x, z = np.genfromtxt(r'40Ca_208Pb_39K_Ex_115deg.dat', unpack=True)
xi = np.linspace(x.min(), x.max(), N)
yi = np.linspace(y.min(), y.max(), N)
zi = scipy.interpolate.griddata((x, y), z, (xi[None,:], yi[:,None]), method='linear')
hfont = {'fontname':'Palatino'}
fig = plt.figure(facecolor="white")
zi = np.ma.masked_less(zi, 1e-7)
plt.contourf(xi, yi, zi,levels=[1e-7,1e-6,1e-5,1e-4,1e-3,1e-2,1e-1],cmap=plt.cm.jet,norm = LogNorm())
plt.xlabel("$E_{x}$")
plt.ylabel("$E/V_{B}$")
plt.colorbar()
plt.show()
我试图在指针的帮助下打印数组的元素,但它给了我一个错误。请看看上面的代码帮助我?
答案 0 :(得分:2)
你需要这样的东西:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int a[6] = {1,2,3,4,5,6};
int *p = a;// storing base address
printf("%d\n", *p);
printf("%d\n", *(p + 1));
}