我正在尝试绘制一个3D表面,以适应python中的某些{x,y,z}点 - 理想情况下就像Mathematica ListSurfacePlot3D函数.到目前为止,我已经尝试plot_surface并且plot_wireframe在我的观点上无济于事.
只有轴渲染plot_surface.plot_wireframe给出了一堆波浪状的,隐约在对象的形状,但不是文档中显示的漂亮的排序:
与以下结果比较ListSurfacePlot3D:

这是一个最小的工作示例,使用我在这里发布的test.csv文件:
import csv
from matplotlib import pyplot
import pylab
from mpl_toolkits.mplot3d import Axes3D
hFile = open("test.csv", 'r')
datfile = csv.reader(hFile)
dat = []
for row in datfile:
dat.append(map(float,row))
temp = zip(*(dat))
fig = pylab.figure(figsize=pyplot.figaspect(.96))
ax = Axes3D(fig)
Run Code Online (Sandbox Code Playgroud)
然后,要么
ax.plot_surface(temp[0], temp[1], temp[2])
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
要么
ax.plot_wireframe(temp[0], temp[1], temp[2])
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
这是它渲染的方式plot_surface:
和使用plot_wireframe:
和使用ListSurfacePlot3D:

将相当复杂的图(特别是ListDensityPlot)导出为PDF或EPS(例如,用于发布)时,生成的文件大小可能非常大.例如:
data = Flatten[Table[{f0, f, Exp[-(f - f0)^2/25^2]}, {f0, 500, 700, 5}, {f, 300,
900}], 1];
plot=ListDensityPlot[data,PlotRange->{Automatic,Automatic,{0,1}},InterpolationOrder->0]
Run Code Online (Sandbox Code Playgroud)

此示例数据集的大小与我通常使用的大小相同.当我使用导出时Export["C:\\test.pdf", plot],它生成一个23.9MB的PDF文件.如果我反而尝试Export["C:\\test1.pdf", Rasterize[plot]]它会小得多,但图像的完整性和可重复性自然会受到影响.
如果我的实际数字是一个组合图,例如(编辑:f转到900),这将进一步复杂化
plot2 = Show[plot, Plot[x, {x, 500, 900}, PlotStyle -> Thick]]
Run Code Online (Sandbox Code Playgroud)

(或使用某些用法Epilog)我喜欢将背景ListDensityPlot光栅化,但保留其他标记并以"矢量"形式绘制.或者至少,帧标签是非光栅化的.
有没有办法做到这一点?
或者,通过其他一些聪明的方法来实现相同的目标?
我已经检查了相关的问题,但这需要比它需要的更复杂(主要是导出然后导入).我已经能够利用该问题中的一些技巧来分别从轴中提取图:
axes = Graphics[{}, Options[plot2]]
Run Code Online (Sandbox Code Playgroud)

plots = Graphics[plot2[[1]]]
Run Code Online (Sandbox Code Playgroud)

但是,在plots长期失去AspectRatio和PlotRange等plots可以用被击中Rasterize,但它需要的尺寸固定.
然后,如何将它们组合在一起?
我有一个精心打造的Control-S反射(即我痴迷地保存我的工作),但是当Mathematica崩溃时,文件打开,当我重新启动Mathematica并打开文件时,保存的更改无法恢复.它在我第一次打开它之前恢复到文件的状态,然后进行(并保存)任何更改.
我怎样才能真正保存我的工作,而无需保存,关闭和重新打开笔记本,具有与我"保存"相同的强迫性规律?
我在Windows XP x64机器上运行Mathematica 8.0.
编辑:只是为了澄清,我并不担心崩溃.我担心的是保存而不是实际储蓄.
我试图将字符串数组从C传递到Fortran子例程,以及从Fortran传递到相同的Fortran子例程。我已经成功地从C和Fortran中成功传递了单个字符串(即1D字符数组)。但是,我在处理字符串数组时遇到了麻烦。我在Fortran端使用ISO C绑定,理想情况下,我希望在调用端尽可能做到无缝。
我已经阅读了一些相关的问题和答案。有些(即this和this)只是“使用ISO C”而没有更多细节,这并没有太大帮助。这个答案非常有帮助(对不同问题的类似答案),但是仅适用于单个字符串,其中似乎在单个Fortran字符串中识别了c_null_char。如果没有两个单独的例程,我无法弄清楚数组情况该怎么办。
我现在有一个C例程,我想从其中传递字符串数组(string):
#include <iostream>
extern "C" void print_hi_array(char input_string[][255]);
using namespace std;
int main() {
char string[3][255] = {"asdf","ghji","zxcv"};
print_hi_array(string);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并且,一个类似的Fortran例程:
program main
implicit none
call print_hi_array( (/"asdf", "ghji", "zxcv"/) )
end program
Run Code Online (Sandbox Code Playgroud)
到目前为止,这是我对接收端的要求:
subroutine print_hi_array(input_string) bind(C)
use iso_c_binding, only: C_CHAR, c_null_char
implicit none
character (kind=c_char, len=1), dimension (3,255), intent (in) :: input_string
character (len=255), dimension (3) :: regular_string
character (len=255) :: dummy_string
integer …Run Code Online (Sandbox Code Playgroud) 我试图理解这段代码的作用(如果它甚至允许的话):
int * A;
int * B;
A = (int *)malloc( size_t somenumber );
B = A;
// bunch of stuff using B, B++, etc.
Run Code Online (Sandbox Code Playgroud)
我读过的所有内容总是使用引用运算符(&)或derefernce运算符(*)来显示将指针等同于指针.
这种等同做了什么?
而且,当我最终free(A)发生什么事情B?