# 图片的基本设置

以下的例子都通过调用Axes方法的方式进行绘制

`Axes`

## 刻度

* 设置坐标轴上的刻度

```python
fig,ax=plt.subplots(figsize=(10,6)) ##设置图片长宽
ax.set_xticks(np.arange(0,11,1))   ##设置11个坐标
```

* 修改坐标轴上显示的值

```python
ax.set_xticklabels([0, 1, 2, 3, 4, 5, 6, 7, 8, 9,r'>10']) ##修改刻度上显示的值
```

* 设置tick label的字体、颜色、大小、角度等

```python
ax.set_xticklabels(
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,r'>10'],
    size='10',   ##字体大小
    rotation=45,    #修改刻度坐标的角度
    horizontalalignment='left',  ##水平方向的对齐方式
    color='red'   ##字体的颜色
    ) ##修改刻度值
###使用字典的方式进行修改
ax.set_xticklabels(
    ['reference','PacBio'],
    fontdict={
        'size':'13',
        'rotation':'45', ##旋转45度
        'horizontalalignment':'left'
    }
                  )
```

* 设置显示的上限

```bash
ax.set_ylim(0,10)
```

* 翻转坐标轴刻度和设置刻度线的位置

```bash
ax.xaxis.set_ticks_position('top')  # 设置x轴刻度线的位置
ax.invert_xaxis()  # 翻转x轴
ax.yaxis.set_ticks_position('right')  # 设置刻度线的位置
ax.invert_yaxis()  # 翻转y轴
```

* 在不改变刻度labels的情况下修改字体大小

  前面利用`set_xticklabels`函数修改labels字体大小时，必须要指定每个labels

```bash
plt.yticks(size=14)
```

### 图例

修改图片的文字大小

```python
ax.legend(wedges, ingredients,
          title="Isoform type",
          loc="center left",
          bbox_to_anchor=(1, 0, 0.5, 1),
          fontsize=12,  ##设置图例文字大小
          title_fontsize=14  ##设置图例title大小
         )
```

### 坐标轴

* 隐藏坐标轴

```bash
# 隐藏对应的坐标轴
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)
```

#### 绘制矩形

使用line2D对象，绘制线条通过增加宽度变成矩形

```bash
import matplotlib.lines as lines
axe.add_line(
                lines.Line2D(
                    [0.6,0.7],
                    [10,10],
                    linewidth=10,
                    solid_capstyle='butt',
                    solid_joinstyle='miter',
                    antialiased=False,
                    color='#00b8a9')
)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zpliu.gitbook.io/booknote/python/matplotlib/tu-pian-de-ji-ben-she-zhi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
