Image localization problem

Hello,

I’m trying to get effect like this (without numbers):

Main bar (canvas black) is 100 width, and status bar (image) is 60 width
In hierarchy the black one is the parent (Canvas) to the yellow one.

The easiest way how to place image like expected is:
set the pivot point is top-left to the canvas (canvas is a hierarchy parent)
set the start-point as 10, and the image width as 60.

The problem is I cannot repeat is by script:

public class Stat_Bar : MonoBehaviour
{
    int x_min = 10;
    int x_max = 60;
  
    void Start()
    {
        RectTransform rt = GetComponent(typeof(RectTransform)) as RectTransform;
        rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0);
        rt.localPosition = new Vector3(x_min, 0, 0);
        rt.sizeDelta = new Vector2(x_max, 15);
    }
}

It looks the setting to left edge is not working: the x_min is a distance from center of parent.
Any suggestions how to set x_min as left edge of hierarchy parent?

Please note that this is a UI question and the UI forums are here. You are far more likely to get an answer there than here.