# Matplotlib drawing, please can you set the subscript to start at 1 instead of 36

**URL:** <https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [February 22, 2023, 1:36am UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927 "2023-02-22T01:36:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![moailaozi](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@moailaozi](https://community.wandb.ai/u/moailaozi)\
**Post date:** [February 22, 2023, 1:36am UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927/1 "2023-02-22T01:36:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/d/d90cdbb2e0a509504a054f682f89557c60393270.png)

```auto
def plot_embeddings(embeddings, label,dataset_name,epoch):
    len_embedding = len(embeddings)
    emb_list = np.array(embeddings.tolist())
    label = np.array(label.tolist())

    color_idx = {}
    for i in range(len_embedding):
        color_idx.setdefault(label[i], [])
        color_idx[label[i]].append(i)

    fig, ax = plt.subplots(figsize=(20,10), dpi= 120)
    for c, idx in color_idx.items():
        ax.scatter(emb_list[idx, 0], emb_list[idx, 1], label=c)

    wandb.log({f"visualization/Embedding——{dataset_name}": fig,
               f"visualization/epoch": epoch,
               })

```

---

<div class="post-metadata">

**Author:** ![mohammadbakir](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mohammadbakir](https://community.wandb.ai/u/mohammadbakir)\
**Post date:** [February 23, 2023, 6:33pm UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927/2 "2023-02-23T18:33:51Z")

</div>

Hi @moailaozi , happy to help. From the screenshot provided this indicates that you began logging your charts at step 36. When executing your code did you make previous `wandb.log` calls in your script prior to creating the charts above? With every call to `log()`, wandb monotonically increase the step value. I checked one of your other projects and you were successful in logging similar charts that began at step 1 of the slider. More on bundle metrics into the same log() call [here](https://docs.wandb.ai/guides/track/log/logging-faqs#why-am-i-seeing-fewer-data-points-than-i-logged). Please let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![moailaozi](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@moailaozi](https://community.wandb.ai/u/moailaozi)\
**Post date:** [February 26, 2023, 3:58am UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927/3 "2023-02-26T03:58:22Z")

</div>

Thank you for your reply, but I still can’t solve this problem. I tried the following methods but nothing worked.

1：

```auto
    with wandb.init(project=project_name,config=args,name= model_name):
        # define our custom x axis metric
        wandb.define_metric("visualization/epoch")
        # define which metrics will be plotted against it
        wandb.define_metric(f"visualization/T-SNE——{args.target_dataset_name}", step_metric="visualization/epoch")
        wandb.define_metric(f"visualization/Embedding——{args.target_dataset_name}", step_metric="visualization/epoch")
        train(model_name,args)

```

2：

```auto
def plot_embeddings(embeddings, label,dataset_name,epoch):
    len_embedding = len(embeddings)
    emb_list = np.array(embeddings.tolist())
    label = np.array(label.tolist())

    color_idx = {}
    for i in range(len_embedding):
        color_idx.setdefault(label[i], [])
        color_idx[label[i]].append(i)

    fig, ax = plt.subplots(figsize=(20,10), dpi= 120)
    for c, idx in color_idx.items():
        ax.scatter(emb_list[idx, 0], emb_list[idx, 1], label=c)

    wandb.log({f"visualization/Embedding——{dataset_name}": fig,
               "visualization/epoch": epoch
               })
    return

```

By changing the coordinates, it still doesn’t change the index

 ![image](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/a/adfa184333c081dbbe5678b482055a76bd870598.png)

---

<div class="post-metadata">

**Author:** ![mohammadbakir](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@mohammadbakir](https://community.wandb.ai/u/mohammadbakir)\
**Post date:** [March 8, 2023, 6:59pm UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927/4 "2023-03-08T18:59:28Z")

</div>

Hi @moailaozi , thank you for providing a code example. There isn’t a specific issue with your functions, but rather I believe you are not nesting your log calls. I reviewed a recent project and noticed the following. Three of your visualizations begin at different steps. This is due to when creating each visualization you either did not initialize a new wandb run, or you logged each one with separate log calls. As mentioned above, With every call to `log()` , wandb monotonically increase the step value.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/2X/8/8f9da1ca316499529893fd10c6e8e7dde873f5f7.png)

To prevent unintended behavior with logging steps, we recommend you nest your log calls. e.g `wandb.log({"Viz1": <vizualization-logic>, "Viz2": <vizualization-logic>)`. This ensures with every log call the graphs step are incremented together.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [May 7, 2023, 7:00pm UTC](https://community.wandb.ai/t/matplotlib-drawing-please-can-you-set-the-subscript-to-start-at-1-instead-of-36/3927/5 "2023-05-07T19:00:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
