以下是我的代码和情节:
import matplotlib
import matplotlib.mlab as mlab
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
delta = 0.00025
A=0
x = np.arange(0, 0.10, delta)
y = np.arange(0, 0.1, delta)
X, Y = np.meshgrid(x, y)
Z = A*(X**2+Y**2)+2*X*Y
manual_locations = [(0.1,0.1), (0.2,0.2), (0.3,0.3),
(0.015, 0.015), (0.00255, 0.0025), (0.00005,0.00005)]
line_widths = (1, 1, 1, 1, 1, 1)
plt.figure()
CS = plt.contour(X, Y, Z, 6, # add 6 contour lines
linewidths=line_widths, # line widths
colors = line_colours) # line colours
plt.clabel(CS, inline=1, # add labels
fontsize=10, # label font size
manual=manual_locations) # label locations
plt.title('Indifference Map') # title
plt.show()
似乎我的manual_locations什么也没做,python自动选择等距轮廓线。虽然我想调查0附近的更多细节。我怎样才能看到更多曲线/等高线收敛到(0,0)? 提前谢谢。
答案 0 :(得分:2)
更详细地探索部分数据的最简单方法是使用 <?php
use yii\helpers\Html;
use app\modules\admin\models\TransLabels;
use app\modules\admin\models\TransText;
$ids = $_GET['id'];
// echo $ids;
$model = TransLabels::find()->where(['trans_page_title' => $ids])->all();
// echo '<pre>';print_r($model);die();
?>
<table class="table table-striped table-bordered" >
<thead>
<tr>
<th>Labels</th>
<th>English</th>
<th>Spanish</th>
<th>French</th>
<th>German</th>
</tr>
</thead>
<tbody>
<form action="<?php echo Yii::$app->homeUrl;?>admin/text/translate" method="post" >
<?php
if (Yii::$app->session->hasFlash('success')) {?>
<div>
<center><h1><span style="color:green; text-align:centre "><?php
print_r(Yii::$app->session->getFlash('success'));
?> </span></h1></center>
</div>
<?php }
?>
<?php
foreach($model as $expertn)
{
$title=$expertn['trans_labels'];
$label_id = $expertn['trans_label_id'];
$sql = TransText::find()->where(['trans_text_label'=>$label_id])->all();
$eng = $sql[0]->English;
$span = $sql[0]->Spanish;
$fren = $sql[0]->French;
$ger = $sql[0]->German;
$text_id = $sql[0]->trans_text_id;
// echo '<pre>';print_r($ger);
// echo $expertn['trans_label_id'];
echo '<tr>'; // start a new row
echo '<td data-label="Payment">';
echo $expertn['trans_labels'];
echo '<input type="hidden" name="text_id[]" value="'.$text_id.'"/>';
echo '<input type="hidden" name="label_id[]" value="'.$expertn['trans_label_id'].'"/>';
echo '</td>';
echo '<td data-label="Issue Date">';
echo '<input type="text" name="english[]" value="'.$eng.'"/>';
echo '</td>';
echo '<td data-label="Issue Date">';
echo '<input type="text"name="spanish[]" value="'.$span.'"/>';
echo '</td>';
echo '<td data-label="Issue Date">';
echo '<input type="text"name="french[]" value="'.$fren.'"/>';
echo '</td>';
echo '<td data-label="Issue Date">';
echo '<input type="text"name="german[]" value="'.$ger.'"/>';
echo '</td>';
// echo '<td>';
// echo $expertn['tcount'];
// echo '</td>';
echo '</tr>';
}
echo '<input type="submit" name="submit" id="sub" value="Save" class="btn btn-primary bton"/>';
?>
</form>
</tbody>
</table>
。这将设置要检查的Z值,并在您的问题中将此短语称为要检查的(x,y)位置,但它与levels
如何工作以直接指定位置点相反。
您还可以通过适当更改绘图的边界来检查(0,0)区域。
下面,我使用contour
的日志值,但线性值同样有效,更常见,更易于理解。日志值很容易强调您最感兴趣的部分。
levels
如果您确实需要特定位置的轮廓,可以将该位置的(x,y)值放入等式中以计算该位置的z值,然后将此值用作其中一个值在import matplotlib
import matplotlib.mlab as mlab
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
#%matplotlib inline
delta = 0.00025
A=0
x = np.arange(0, 0.10, delta)
y = np.arange(0, 0.1, delta)
X, Y = np.meshgrid(x, y)
Z = A*(X**2+Y**2)+2*X*Y
manual_locations = [(0.1,0.1), (0.2,0.2), (0.3,0.3),
(0.015, 0.015), (0.00255, 0.0025), (0.00005,0.00005)]
line_widths = (1, 1, 1, 1, 1, 1)
plt.figure()
CS = plt.contour(X, Y, Z, 6, # add 6 contour lines
linewidths=line_widths,
#levels=np.linspace(0, .003, 20))
levels=np.logspace(-5, -2, 20))
plt.clabel(CS, inline=1, # add labels
fontsize=10,
fmt="%.5f")
plt.title('Indifference Map') # title
plt.show()
参数中。