How was computer graphics libraries or gtk,qt programmed? I am wondering how was first graphic or image libraries created,I know C and Python ,I want to create plotting application,and I cant imagine these libraries(QT,OpenGL,Vulkan) written by C,how can I create my image library,I just want to create basic graphic library.
You're asking about two different types of library. OpenGL and Vulkan aren't just libraries: they're hardware interfaces. They are implemented by GPU vendors so that application developers can access the GPU, like a special kind of hardware driver. They're implemented in C or C++ and the core functionality is implemented by writing some structures in memory that the GPU itself can understand, then writing to registers on the GPU to make it read those structures and do the work. There isn't any C code in OpenGL to transform triangles, compute their projection onto the screen, and shade them, because that work is all done by the GPU.

OTOH, Qt and Gtk are libraries for making applications. A lot of their work isn't about graphics: they provide a framework for applications to manage themes and interactivity, letting the application developer wire together different parts of the application with callbacks. This is just normal library code. They also provide GUI classes such as buttons and checkboxes. These will each have something like a "draw" function which draws the graphics on the screen. A few years ago this would commonly have been implemented using the OS's 2D drawing API (e.g. GDI on Windows), which offers operations like "draw a filled rectangle", "blit an image", but nowadays they're more likely to use OpenGL or Vulkan operations. The UI components are defined in images and they're used as textures to generate the image of the whole window via a sequence of OpenGL draw calls.

You wouldn't implement OpenGL or Vulkan: this is something that GPU vendors create. You can't really do it yourself without detailed knowledge of the GPU hardware. (However, Mesa is an example of a software implementation of OpenGL, which doesn't depend on any GPU.)

If you wanted to implement a GUI library like Qt, you might start by defining an abstract Widget class with a draw method, and then implementing concrete subclasses of it to draw particular GUI components. Add extra methods and functionality as you need it.

To be honest, I don't think that would be a valuable project to work on. There are many smaller GUI frameworks already, and another toy one is not going to improve the world. You might treat it as just a learning project, but I think you'd learn more by studying one of the existing frameworks and writing an interesting GUI application on top of it.