这是我的代码
import os,sys
import Image
import matplotlib.pyplot as plt
from matplotlib.pyplot import *
from matplotlib.font_manager import FontProperties
jpgfile = Image.open("t002.jpg")
# Set up the figure and axes.
fig = plt.figure(figsize=(18,10)) # ...or whatever size you want.
ax = fig.add_subplot(111)
ax.legend(fontsize=18)
# Draw things.
plt.imshow(jpgfile) # Unlike plot and scatter, not a method on ax.
ax.set_xlabel('normalized resistivities')
ax.set_ylabel('normalized velocities')
ax.set_xticks([]); ax.set_yticks([])
# Save and show.
plt.savefig("fig.jpg")
plt.show()
Run Code Online (Sandbox Code Playgroud)
但
/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:519: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots
Run Code Online (Sandbox Code Playgroud)
我应该如何设置标签?
我正在使用教程point.com示例.
int var[MAX] = {10, 100, 200};
int *ptr;
// let us have address of the last element in pointer.
ptr = &var[MAX-1];
for (int i = MAX; i > 0; i--)
{
cout << "Address of var[" << i << "] = ";
cout << ptr << endl;
cout << "Value of var[" << i << "] = ";
cout << *ptr << endl;
// point to the previous location
ptr--;
}
return 0;
Run Code Online (Sandbox Code Playgroud)
那么,&var[MAX - 1]
为什么不 …
#include<iostream>
#include<fstream>
using namespace std;
class Integer {
public:
int val;
Integer(int val = 0) {
this->val = val;
}
void setVal(int val) {
this->val = val;
}
};
int main()
{
int val;
Integer i;
i.setVal(8);
cout << val << endl;
}
Run Code Online (Sandbox Code Playgroud)
当我执行我的代码时,我得到了0
.我是C++的新手,我不明白this
.有人可以详细说明这个问题吗?
我想将浮点数列表转换为整数.我的代码
import math
data1 = [line.strip() for line in open("/home/milenko/Distr70_linux/Projects/Tutorial_Ex3/myex/base.txt", 'r')]
print type(data1)
data1c = [int(math.floor(i)) for i in data1]
print data1c[0]
Run Code Online (Sandbox Code Playgroud)
我应该改变什么?文件很大,只有几行
1.200000e+03
1.200000e+03
1.200000e+03
1.200000e+03
1.200000e+03
1.200000e+03
1.200000e+03
1.200000e+03
Run Code Online (Sandbox Code Playgroud) with open('index.txt','r') as f:
a = [int(x) for x in f.readline().split()]
array = []
for line in f:
array.append([int(x) for x in line.split()])
print array[0]
print array[1]
print array[2]
print array[3]
print array[4]
Run Code Online (Sandbox Code Playgroud)
输入文件
0
0
100
200
1
101
201
2
102
202
3
103
Run Code Online (Sandbox Code Playgroud)
当我运行我的代码
[0]
[100]
[200]
[1]
[101]
Run Code Online (Sandbox Code Playgroud)
刚刚0
出现.
我正在努力解决这些概念。例如,我有这个视图函数
def post_detail(request, year, month, day, post):
post = get_object_or_404(Post, slug=post,status='published',p__year=year,p__month=month,p__day=day,status='published',)
return render(request,'blog/post/detail.html',{'post': post})
Run Code Online (Sandbox Code Playgroud)
据我了解,函数将请求对象作为参数、模板路径和变量来呈现给定的模板。直到现在还可以。但是现在来了模板上下文处理器和幕后的魔法。来自djangoproject
该
TEMPLATE_CONTEXT_PROCESSORS
设置是一个可调用元组 - 称为上下文处理器 - 将请求对象作为参数并返回要合并到上下文中的项目字典
他们实际上在做什么?他们将在模板中公开数据,输入数据是否有任何限制?
过滤功能
function filter(array,test) {
let passed = [];
for (let element of array){
if (test(element)) {
passed.push(element);
}
}
return passed;
}
Run Code Online (Sandbox Code Playgroud)
大批
a = [{name: 'John', sport : 'football'},
{name: 'Sergio', sport : 'football'},
{name: 'John', sport : 'basketball'},
{name: 'Jova', sport : 'football'},
{name: 'Jon', sport : 'basketball'},
{name: 'Lemmi', sport : 'football'},
{name: 'Josh', sport : 'football'},
]
Run Code Online (Sandbox Code Playgroud)
当我运行我的代码时
console.log(filter(a, i => i.name['Lemmi']));
Run Code Online (Sandbox Code Playgroud)
我有
[]
Run Code Online (Sandbox Code Playgroud)
如何编辑行以获取
sport: 'football'
Run Code Online (Sandbox Code Playgroud)
输出?
我想规范化(在0和1之间缩放值)矢量速度.
normalized v(i)=v(i)-vmin/(vmax-vmin)
Run Code Online (Sandbox Code Playgroud)
我的代码
#include <iostream>
#include <iterator>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<double> velocity;
vector<double> results;
double vLower, vUpper, v1;
ifstream inputFile1("/home/milenko/gust/vel.dat");
if (inputFile1) {
double value;
while ( inputFile1 >> value ) {
velocity.push_back(value);
}
}
vLower = *min_element(velocity.begin(), velocity.end());
vUpper = *max_element(velocity.begin(), velocity.end());
v1 = vUpper-vLower;
transform(velocity.begin(), velocity.end(), velocity.begin(), [vLower](double i) -> double { return i - vLower; });
transform (velocity.begin(), velocity.end(), v1, results, divides<double>());
for (auto c : results) { …
Run Code Online (Sandbox Code Playgroud) 我的csh脚本
#!/bin/csh
# C-schell script to increase the boundingbox....
echo '%\!PS-Adobe-3.0 EPSF-3.0'
echo '%%BoundingBox: 0 0 1100 1100'
tail +3 $argv[1]
Run Code Online (Sandbox Code Playgroud)
叫这里
csh bbox.csh plt >! plt_P1.ps
Run Code Online (Sandbox Code Playgroud)
但是我有
csh -f bbox.csh plt
tail: cannot open ‘+3’ for reading: No such file or directory
Run Code Online (Sandbox Code Playgroud)
该怎么tail
办?编写代码的人使用Darwin,我在Ubuntu 14.04上.
这是我的代码
#!/usr/bin/R
c1 <-c(60,199,102,134,81,95,135,151,102,112,211,120)
barplot(c1, main="number of points per cluster",
color="dark blue")
Run Code Online (Sandbox Code Playgroud)
但警告信息说
警告消息:1:在plot.window(xlim,ylim,log = log,...)中:
"color"不是图形参数
我还想在x轴上从1到12编号.