# CImGui.PlotLines and CImGui.PlotHistogram problems

**URL:** <https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831>\
**Category:** General Usage\
**Tags:** question, array\
**Created:** [September 16, 2019, 9:55pm UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831 "2019-09-16T21:55:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Post date:** [September 16, 2019, 9:55pm UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/1 "2019-09-16T21:55:20Z")

</div>

I have a problem with these CImGui functions.  
It should plot my Array, but it take every second second value from my Array, and every second value from “I don’t know?” I checked my array values and there’s any problem with that. Even on the image which I uploaded the maximum value of Bplane array is equal 29.17 A/m and some of these bars are even order of 7 or more for example this 3.117e+007 which is seen on this image.  
It looks like that:

 ![problem](https://global.discourse-cdn.com/julialang/original/3X/4/7/477a499eb51baafc775687a79a32ceeb1e5d0705.png)  
And some brief code:

```julia
@cstatic X=Cfloat[-10.0, 0.20, 10.0] Y=Cfloat[-10, 0.20, 10.0] Yplane=Cint(1) Unit=Cint(0) begin
              if @isdefined B
                if @c CImGui.VSliderInt("##v", ImVec2(bar_width,img_height), &Yplane, 1, length(y), @sprintf("%g m",y[Yplane]))
                        global plane=Yplane
                end
                Bplane=B[:,plane]*coefficient 
                CImGui.SameLine()
                # CImGui.Text("$Bplane")
             
                @c CImGui.PlotHistogram("Histogram", Bplane, length(Bplane), 0, C_NULL, 0.0, maximum(Bplane), ImVec2(img_width,img_height))

```

B is created in button:

```julia
if CImGui.Button("Generate plot")
x=X[1]:X[2]:X[3]
y=Y[1]:Y[2]:Y[3]
...
global B=...
...
end

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 17, 2019, 4:58am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/2 "2019-09-17T04:58:45Z")

</div>

did you convert those values passed to CImGui to Cfloat?

---

<div class="post-metadata">

**Author:** ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Post date:** [September 17, 2019, 7:40am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/3 "2019-09-17T07:40:22Z")

</div>

I added Bplane=Cfloat.(B[:,plane)) and all works. Thank you.

---

<div class="post-metadata">

**Author:** ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Post date:** [September 17, 2019, 5:59pm UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/4 "2019-09-17T17:59:50Z")

</div>

I have one more question. Is any way to display a tooltip text in this `CImGui.PlotLines` in different format. It means for example I have two tables. One is this value table(Bplane) and second is x table(coordinate table). So I want to display instead this what is showed on this uploaded image(`24: 3.117e+007`) in format (`-5.2: 3.117e+007`) or even better(`X=-5.2 m B=3.117e+007 A/m`). That -5.2 is taken from `x=-10:0.2:10` steprange eventually `x=collect(-10:0.2:10)` Array/List. Now this tooltip show something like values for every `i` point hovered in format: `("$i: $(Bplane[i])")` and I want it in format: `("$(x[i]): $(Bplane[i])")` or better `("X=$(x[i]) m: B=$(Bplane[i]) A/m")`.

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 18, 2019, 6:51am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/5 "2019-09-18T06:51:54Z")

</div>

It looks like `PlotHistogram` accepts an argument called “overlay\_text” which is likely for custom tooltip format.

---

<div class="post-metadata">

**Author:** ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Post date:** [September 18, 2019, 10:33am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/6 "2019-09-18T10:33:38Z")

</div>

I know this, but that’s need this extra CImGui.ItemHovered statement and this build-in tooltip with PlotLines/PlotHistogram is almost completed. And if I would use this overlay as a tooltip I would have to clear this PlotLines/PlotHistogram Tooltip.

 ![overlay](https://global.discourse-cdn.com/julialang/original/3X/4/a/4afc77a9a9a3f7fd1b5ad02af675ab37b9026479.png)

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 19, 2019, 1:24am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/7 "2019-09-19T01:24:54Z")

</div>

currently there is no workaround, the tooltip format is hard-coded to `"%d: %8.4g"`:

[https://github.com/ocornut/imgui/blob/9d02ed51e3d10e6aff09d10871e7b55b3475dd95/imgui\_widgets.cpp#L5769](https://github.com/ocornut/imgui/blob/9d02ed51e3d10e6aff09d10871e7b55b3475dd95/imgui_widgets.cpp#L5769)

related issue: [https://github.com/ocornut/imgui/pull/201](https://github.com/ocornut/imgui/pull/201)

---

<div class="post-metadata">

**Author:** ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Post date:** [September 19, 2019, 7:52am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/8 "2019-09-19T07:52:37Z")

</div>

Ok, I used this SetTooltip instead of beginTooltip which I usually use and it works.

```julia
if CImGui.IsItemHovered()
    region_x = Cint(div(length(x)*(io.MousePos.x - pos.x),img_width)+1)
    CImGui.SetTooltip(@sprintf("X = %g m \n B = %.2f", x[region_x], Bplane[region_x]))
end

```

Thank you. Still have problem with Greek characters, if you could help, here’s my other problem [CImGui Greek Characters](https://discourse.julialang.org/t/cimgui-greek-characters/28918).

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 19, 2019, 8:09am UTC](https://discourse.julialang.org/t/cimgui-plotlines-and-cimgui-plothistogram-problems/28831/9 "2019-09-19T08:09:44Z")

</div>

> [@wiktorkujawa](#):
>
> Still have problem with Greek characters

I’m not familiar with those font-related stuff too(and I can’t even distinguish Greek and Latin characters 😛 ). As this is a question about Dear IMGUI itself, I guess you would get more help if you post this to Dear IMGUI’s discourse forum.
