Drawing is translated to fairly primitive commands at the lowest level. Such as
- Draw Line/Ellipse/Polyline/spline
- Fill ellipse/rectangle/polygon
- Draw pixels from image X at position Y using blending mode Z
- Draw string X at position Y using font Z
- etc...
These commands can be implemented in software using various algorithms 1 2 3. Software rendering may be done by the OS, or the application itself. It may also be hardware accelerated where these commands are sent to dedicated 2D graphics hardware. Commands can also be translated to use the 3D graphics API, so drawing a line may be achieved by drawing a pair of thin triangles for example. The OS may use different methods depending on the API used, the hardware available etc.
There is 50-ish years of research and development on how to efficiently draw graphics, some that has been obsoleted by improvements in hardware and technology. So it is not a topic that can be easily summarized.
I'm not familiar with TK, but as far as I can tell it seems like an abstraction layer on top of the OS, so would translate drawing commands to whatever OS it runs on. But I would not be chocked if things like plots are drawn by the application itself using some software rendering library. Drawing plots are probably not that performance sensitive, and it may be easier to ensure plots look the same on all OSes if you do the drawing yourself.
Long ago applications would do their drawing to a shared frame buffer on the graphics card before sending it to the screen. But for modern operating systems there will be separate buffers for each application/window, and there will very likely be additional buffers as needed. All the frame buffers will be combined by the OS during the "compositing" stage to produce a final image to send to the screen.